File: 04_rich_markup.py

package info (click to toggle)
python-rich-click 1.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 520 kB
  • sloc: python: 1,017; sh: 25; makefile: 9
file content (35 lines) | stat: -rw-r--r-- 953 bytes parent folder | download
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
import rich_click as click

# Use Rich markup
click.rich_click.USE_RICH_MARKUP = True


@click.command()
@click.option(
    "--input",
    type=click.Path(),
    help=r"Input [magenta bold]file[/]. [dim]\[default: a custom default][/]",
)
@click.option(
    "--type",
    default="files",
    show_default=True,
    help="Type of file to sync",
)
@click.option("--all", is_flag=True, help="Sync all the things?")
@click.option("--debug", is_flag=True, help="Enable :point_right: [yellow]debug mode[/] :point_left:")
def cli(input, type, all, debug):
    """
    My amazing tool does [black on blue] all the things [/].

    This is a [u]minimal example[/] based on documentation
    from the [link=https://click.palletsprojects.com/]'click' package[/].

    [i]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'}")


if __name__ == "__main__":
    cli()