Skip to content

Commit 7ff4ad9

Browse files
committed
Fix package
1 parent 7658ed3 commit 7ff4ad9

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
# cli-context
22
This is a library which supports CLI contexts for action hierarchies.
33
For that, you have to use the `CliContext` class and create your own contexts.
4+
5+
## Usage
6+
Install this package with pip (or manually).
7+
8+
In your project, create a python file which will be called as a CLI entry-point:
9+
```python
10+
import sys
11+
from .my_entry_context import context as entry_ctx
12+
13+
14+
if __name__ == "__main__":
15+
entry_ctx.run((sys.argv[0],), sys.argv[1:])
16+
```
17+
18+
In `my_entry_context.py`:
19+
```python
20+
from cli_context import CliContext
21+
22+
context = CliContext(
23+
"This is my fancy CLI",
24+
sub_contexts={
25+
"run": run_context,
26+
"do": another_context,
27+
}
28+
)
29+
30+
```

cli-context/__init__.py

Whitespace-only changes.

cli_context/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .cli_context import CliContext

cli-context/cli_context.py renamed to cli_context/cli_context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def print_help(self, program):
2929
program_str = " ".join(program)
3030

3131
print("usage: %s <command> [<args>]" % program_str)
32+
print("\n" + self.description)
3233

3334
if len(self.sub_contexts) > 0:
3435
print("\nCommands:")

0 commit comments

Comments
 (0)