A sample Poetry project with a CLI and custom Python code
Project description
A small repo dedicated to desigining a CLI tool with Python via Click and built by the Poetry. For details, see:
Instructions
-
pip install poetry|pip install click- install poetry module -
poetry install- install project dependencies[!NOTE]
If you need to add dependencies again for poetry (it is its own virtual env), use :poetry add requests. -
poetry run mycli "hello world"- test the cli -
poetry build- build the /dist folder -
pip install dist/my_cli_project-0.1.0.tar.gz- install the cli locally -
Open a new terminal window and try the cli:
mycli --help -
(Optional)
poetry publish- publish to pypi requires credentialspoetry config repositories.my-repo https://my-repo-url/simple/ poetry config http-basic.my-repo username password poetry publish --repository my-repo -
Open a new terminal window. Run the following command(s):
Command Description mycli return_pokemon --pokemon charizardReturns data or details about the Pokémon named "charizard". mycli greet --name ianPrints a greeting message for the name "ian". mycli reverse abcReverses the string "abc". mycli cap abcCapitalizes the string "abc".
Testing
To run the test files in /tests, from the root directory execute the following command:
poetry run pytest
- Todo: possible to use runner.py to test cli commands more effectively?
Tagging
To add a tag to a branch, use git tag v0.0.1.
To trigger a test build, add a tag matching the v0.0.0 naming convention:
git checkout main
git tag v0.0.1
git push origin refs/tags/v0.0.1
Optionally:
git tag -f v0.0.1 HEAD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file my_cli_project-0.0.1.tar.gz.
File metadata
- Download URL: my_cli_project-0.0.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f1e2937de1ec274a0e4bf4e977221c94c44c657ce628192a96e858187ba9087
|
|
| MD5 |
0e146efe43734b878614bbe4025b803e
|
|
| BLAKE2b-256 |
82bd3cf3324ba3ce618d4038c6dfa596ec783886b1c4e84a5d16f4254d05b51f
|
File details
Details for the file my_cli_project-0.0.1-py3-none-any.whl.
File metadata
- Download URL: my_cli_project-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98c310f7ceb7af452e96d9bcfd2ea215a560b7e96908187a21be6960db7e0975
|
|
| MD5 |
859ee838b7f8b020dc2dfd0138ebfb0c
|
|
| BLAKE2b-256 |
6bf7acf04576af2f7801d72d54fb8566a84088d40f66a9fa8d3e9181b51a7e74
|