Replace optparse with Click
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
As we move forward to 1.4.0, I'd like to tackle on this issue, as suggested by @sampsyo several times.
#### The `click` module
`click`'s API declares commands through decorators. It has a `click.command()` decorator (that replaces the function for an instance of `click.Command()`) and the `click.group()` decorator that can nest other commands. A common use case would be:
``` python
@click.group()
def main():
pass
@main.command(name='import')
def do_import():
pass
```
Or programatically add commands:
``` python
@click.group()
def main():
pass # click.group() replaces the function by a click.Group() object
@click.command(name='import')
def do_import():
pass
main.add_command(do_import)
```
And internally there's a non-decorator interface, but the docs say it should be avoided for high-level usage.
#### To-do list
See #1446
Contributor guide
Research direction
Start with the related work in #1446, then locate the existing optparse command entry points. Compare the current CLI structure with Click's command and group API described in this issue. Done means the CLI has migrated from optparse to Click while preserving its existing commands; no files or tests are named here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100