-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ewels/import-as
Import as
- Loading branch information
Showing
8 changed files
with
181 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import rich_click | ||
|
||
|
||
@rich_click.group() | ||
@rich_click.option( | ||
"--debug/--no-debug", "-d/-n", default=False, help="Enable debug mode" | ||
) | ||
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() | ||
@rich_click.option( | ||
"--type", | ||
required=True, | ||
default="files", | ||
show_default=True, | ||
help="Type of file to sync", | ||
) | ||
@rich_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() | ||
@rich_click.option("--all", is_flag=True, help="Get everything") | ||
def download(all): | ||
"""Pretend to download some files from somewhere""" | ||
print("Downloading") | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import click | ||
import rich_click | ||
|
||
#### | ||
## Rich-click cli stuff | ||
#### | ||
@rich_click.group() | ||
@rich_click.option( | ||
"--debug/--no-debug", "-d/-n", default=False, help="Enable debug mode" | ||
) | ||
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() | ||
@rich_click.option("--all", is_flag=True, help="Sync all the things?") | ||
def sync(all): | ||
"""Synchronise all your files between two places""" | ||
print("Syncing") | ||
|
||
|
||
@cli.command() | ||
@rich_click.option("--all", is_flag=True, help="Get everything") | ||
def download(all): | ||
"""Pretend to download some files from somewhere""" | ||
print("Downloading") | ||
|
||
|
||
#### | ||
## Vanilla click import cli stuff | ||
#### | ||
@click.command() | ||
@click.option("--all", is_flag=True, help="Sync all the things?") | ||
def original(all): | ||
"""Synchronise all your files between two places""" | ||
print("Syncing") | ||
|
||
|
||
if __name__ == "__main__": | ||
cli() # Use rich-click, should be fancy output | ||
# original() # Use vanilla click, should be simple output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.