forked from ewels/rich-click
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01_simple.py
69 lines (54 loc) · 1.58 KB
/
01_simple.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import rich_click as click
@click.group()
@click.option(
"--debug/--no-debug",
"-d/-n",
default=False,
help="""Enable debug mode.
Newlines are removed by default.
Double newlines are preserved.""",
)
def cli(debug):
"""
My amazing tool does all the things.
This is a minimal example based on documentation
from the 'click' package.
You can try using --help at the top level and also for
specific group subcommands.
"""
print(f"Debug mode is {'on' if debug else 'off'}")
@cli.command()
@click.option(
"--type",
required=True,
default="files",
show_default=True,
help="Type of file to sync",
)
@click.option("--all", is_flag=True, help="Sync all the things?")
def sync(type, all):
"""Synchronise all your files between two places."""
print("Syncing")
@cli.command(short_help="Optionally use short-help for the group help text")
@click.option("--all", is_flag=True, help="Get everything")
def download(all):
"""
Pretend to download some files from
somewhere. Multi-line help strings are unwrapped
until you use a double newline.
Only the first paragraph is used in group help texts.
Don't forget you can opt-in to rich and markdown formatting!
\b
Click escape markers should still work.
* So you
* Can keep
* Your newlines
And this is a paragraph
that will be rewrapped again.
\f
Also if you want to write function help text that won't
be rendered to the terminal.
""" # noqa: D301, D400
print("Downloading")
if __name__ == "__main__":
cli()