https://github.com/databio/example_python_cli
A skeleton python package demonstrating how to create a python CLI tool using logmuse.
https://github.com/databio/example_python_cli
Last synced: 11 months ago
JSON representation
A skeleton python package demonstrating how to create a python CLI tool using logmuse.
- Host: GitHub
- URL: https://github.com/databio/example_python_cli
- Owner: databio
- License: bsd-2-clause
- Created: 2019-10-11T12:22:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-01T19:42:12.000Z (over 6 years ago)
- Last Synced: 2025-07-18T10:54:40.946Z (11 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# A Skeleton Python CLI
This repository contains a skeleton that shows you how to create a python package that behaves as a command-line tool. If you install this repository with `pip`, you will then have access to a new shell command called `packagename`.
## Packagename
Install with: `pip install --user .`
Run with: `packagename -i INPUT -p PARAMETER`
See: `packagename --help` for details.
## Make it yours
Just copy all the files in this repository into a new repository and then edit them. You can edit these files to replace `packagename` everywhere with the name of the tool you want to create. Then, just make the function call whatever python code you need it to.
## Explanation
The creation of a command-line tool happens in `setup.py` in the lines that say:
```
entry_points={
"console_scripts": [
'packagename = packagename.packagename:main'
],
},
```
Here `packagename = ...` is the command that will eventually be created; and
then `packagename.packagename` are 1) the name of the folder and then 2) the
name of the file that you want the command to run. Finally, `:main` says to run
the main function in that file.
### Logmuse
This package sets you up automatically to use the *logmuse* package, which gives
your tool parameters like `--verbosity` and `--logdev`, which change the
logging. You can use `_LOGGER.debug()` and `_LOGGER.info()`, and
`_LOGGER.warn()`, *etc*, to emit different classes of error messages. It's
already configured. You can read the logmuse documentation for more info.