Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: CLI dispatcher #63

Merged
merged 7 commits into from Sep 8, 2022
Merged

feature: CLI dispatcher #63

merged 7 commits into from Sep 8, 2022

Conversation

flying-sheep
Copy link
Contributor

@flying-sheep flying-sheep commented Sep 8, 2022

I made all CLI packages follow a convention:

  • def make_parser(parser=None, prog=None) either creates a parser or adds arguments to one that’s being passed
  • def run(args=None) either runs from passed args (argparse.Namespace) or parses sys.argv using make_parser

Together, that allows to maintain backwards compatibility, as python -m hatch_jupyter_builder.migrate is still possible and works the same as the new hatch-jupyter-builder migrate.

Fixes #62

Results:

$ hatch-jupyter-builder -h
usage: hatch-jupyter-builder [-h] {migrate,compare-migrated} ...
...
$ python -m hatch_jupyter_builder -h
usage: /usr/bin/python -m hatch_jupyter_builder [-h] {migrate,compare-migrated} ...

positional arguments:
  {migrate,compare-migrated}

options:
  -h, --help            show this help message and exit
$ hatch-jupyter-builder migrate -h
usage: hatch-jupyter-builder migrate [-h] target_dir
...
$ python -m hatch_jupyter_builder migrate -h
usage: /usr/bin/python -m hatch_jupyter_builder migrate [-h] target_dir
...
$ python -m hatch_jupyter_builder.migrate -h
usage: /usr/bin/python -m hatch_jupyter_builder.migrate [-h] target_dir

positional arguments:
  target_dir  Target Directory

options:
  -h, --help  show this help message and exit
$ hatch-jupyter-builder compare_migrated -h
usage: hatch-jupyter-builder compare_migrated [-h] source_dir target_dir dist_name
...
$ python -m hatch_jupyter_builder compare_migrated -h
usage: /usr/bin/python -m hatch_jupyter_builder compare_migrated [-h] source_dir target_dir dist_name
...
$ python -m hatch_jupyter_builder.compare_migrated -h
usage: /usr/bin/python -m hatch_jupyter_builder.compare_migrated [-h] source_dir target_dir dist_name

positional arguments:
  source_dir  Source Directory
  target_dir  Target Directory
  dist_name   Dist name

options:
  -h, --help  show this help message and exit

@welcome
Copy link

welcome bot commented Sep 8, 2022

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@flying-sheep flying-sheep changed the title Add CLI dispatcher feature: CLI dispatcher Sep 8, 2022
@blink1073 blink1073 added the enhancement New feature or request label Sep 8, 2022
Copy link
Member

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you!

@blink1073
Copy link
Member

Failure is unrelated. Thanks again!

@blink1073 blink1073 merged commit fc91c95 into jupyterlab:main Sep 8, 2022
@welcome
Copy link

welcome bot commented Sep 8, 2022

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@blink1073
Copy link
Member

@flying-sheep
Copy link
Contributor Author

flying-sheep commented Sep 9, 2022

neat, thank you for the quick review and fixing this up with readme changes and so on!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pipx support for migrate script
2 participants