File: cli.md

package info (click to toggle)
knack 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 696 kB
  • sloc: python: 6,261; sh: 8; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CLI
===

CLI provides the entry point.

The CLI object is used as a context, `cli_ctx`, that is passed around throughout the application. You will see this context, `cli_ctx`, referenced frequently.

We recommend specifying `cli_name`, `config_dir` and `config_env_var_prefix`.

For example:
`cli_name` - Name of CLI. Typically the executable name.
`config_dir` - Path to config dir. e.g. `os.path.expanduser(os.path.join('~', '.myconfig'))`
`config_env_var_prefix` - A prefix for environment variables used in config e.g. `CLI_`.

Use the `invoke()` method to invoke commands.

For example:

```Python
mycli = CLI(commands_loader_cls=MyCommandsLoader)
exit_code = mycli.invoke(sys.argv[1:])
```


How do I?
---------

### Show my own version info ###

Subclass `CLI` and override `get_cli_version()`.