Skip to main content

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

  1. pip install poetry | pip install click - install poetry module

  2. 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.

  3. poetry run mycli "hello world" - test the cli

  4. poetry build - build the /dist folder

  5. pip install dist/my_cli_project-0.1.0.tar.gz - install the cli locally

  6. Open a new terminal window and try the cli: mycli --help

  7. (Optional) poetry publish - publish to pypi requires credentials

     poetry config repositories.my-repo https://my-repo-url/simple/
     poetry config http-basic.my-repo username password
     poetry publish --repository my-repo
    
  8. Open a new terminal window. Run the following command(s):

    Command Description
    mycli return_pokemon --pokemon charizard Returns data or details about the Pokémon named "charizard".
    mycli greet --name ian Prints a greeting message for the name "ian".
    mycli reverse abc Reverses the string "abc".
    mycli cap abc Capitalizes 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

my_cli_project-0.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

my_cli_project-0.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

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

Hashes for my_cli_project-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3f1e2937de1ec274a0e4bf4e977221c94c44c657ce628192a96e858187ba9087
MD5 0e146efe43734b878614bbe4025b803e
BLAKE2b-256 82bd3cf3324ba3ce618d4038c6dfa596ec783886b1c4e84a5d16f4254d05b51f

See more details on using hashes here.

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

Hashes for my_cli_project-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98c310f7ceb7af452e96d9bcfd2ea215a560b7e96908187a21be6960db7e0975
MD5 859ee838b7f8b020dc2dfd0138ebfb0c
BLAKE2b-256 6bf7acf04576af2f7801d72d54fb8566a84088d40f66a9fa8d3e9181b51a7e74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page