https://github.com/guillaumefalourd/poc-cli-python
POC of a CLI project using Python 🐍 with Click.
https://github.com/guillaumefalourd/poc-cli-python
cli click poc python
Last synced: 7 months ago
JSON representation
POC of a CLI project using Python 🐍 with Click.
- Host: GitHub
- URL: https://github.com/guillaumefalourd/poc-cli-python
- Owner: GuillaumeFalourd
- Created: 2021-11-23T16:16:33.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-24T14:24:43.000Z (almost 4 years ago)
- Last Synced: 2025-01-12T06:07:12.835Z (9 months ago)
- Topics: cli, click, poc, python
- Language: Python
- Homepage: https://click.palletsprojects.com/en/8.0.x/api/
- Size: 3.96 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# poc-cli-python
POC of a CLI project using Python and [Click 8.0.x](https://click.palletsprojects.com/en/8.0.x/api/) 🐍
## Setup
At the repository root, run:
First:
```bash
python3 -m venv env
```Then:
```bash
source env/bin/activate
```Finally:
```bash
python3 -m pip install --editable .
```### AutoComplete
Run the following command according to the shell you're working with:
**Fish:**
```shell
eval (./auto_complete_fish.sh )
```**Bash:**
```shell
. ./auto_complete_bash.sh
```**Zsh:**
```shell
. ./auto_complete_zsh.sh
```Then, the autocomplete should be activated using ` `

## Usage
After the setup above, you'll be able to use the command by typing `os`:
```bash
➜ os
Usage: os [OPTIONS] COMMAND [ARGS]...Options:
--help Show this message and exit.Commands:
apply
create
describe
list
```Each command has a subcommand stack and template such as `os create`:
```bash
➜ os create
Usage: os create [OPTIONS] COMMAND [ARGS]...Options:
--help Show this message and exit.Commands:
stack
template
```The behaviour is the same with `os list`, `os describe` and `os apply`.
### Callback
Using this annotation in the `cli.py` class allows to execute functions after each command execution.
```python
@cli.resultcallback()
def process_result(result, **kwargs):
click.echo('After command')
```
## Demo


