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

feat: Command aliases #30

Merged
merged 12 commits into from
Aug 7, 2024
Merged

feat: Command aliases #30

merged 12 commits into from
Aug 7, 2024

Conversation

jaykv
Copy link
Owner

@jaykv jaykv commented Aug 7, 2024

Support command aliases with |

i.e. the following manifest

name: testcli
version: 0.1.0

commands:
   list|ls|l: print("listing")
   stuff.remove|rm|r: print("removing stuff")

will print "listing" for testcli list, testcli ls, and testcli l and print "removing stuff" for testcli stuff remove, testcli stuff rm, and testcli stuff r.

Summary by Sourcery

Add support for command aliases in CLI commands, allowing multiple names for a single command using the '|' separator. Enhance CLI generation and add a callback to display aliases. Update documentation and add tests for the new functionality.

New Features:

  • Introduce support for command aliases using the '|' separator in command definitions, allowing multiple aliases for a single command.

Enhancements:

  • Add a callback to display all command aliases when the '--aliases' option is used.
  • Update CLI generation to include alias handling in both base and group commands.

Documentation:

  • Update CLI manifest documentation to include information on defining command aliases.

Tests:

  • Add tests to verify the functionality of command aliases in various CLI commands.

Copy link

sourcery-ai bot commented Aug 7, 2024

Reviewer's Guide by Sourcery

This pull request introduces support for command aliases in the CLI. The changes include updates to the CLI generation logic to handle command aliases, modifications to the manifest and parser to support aliases, and updates to the generated CLI files to include alias handling. Additionally, test cases have been added to verify the functionality of command aliases.

File-Level Changes

Files Changes
cliffy/commanders/typer.py
cliffy/commander.py
cliffy/cli.py
Implemented command alias support in CLI generation and handling.
examples/generated/db.py
examples/generated/town.py
examples/generated/environ.py
examples/generated/hello.py
examples/generated/template.py
examples/generated/penv.py
examples/generated/pydev.py
examples/generated/requires.py
Updated generated CLI files to include command alias handling and aliases option in CLI callback.
examples/db.yaml
examples/town.yaml
Added command aliases in example YAML files.
cliffy/manifests/v1.py Updated CLIManifest class to support command aliases in the manifest.
cliffy/parser.py Updated parser to handle command aliases.
tests/test_examples.py Added test cases for command aliases.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @jaykv - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 3 issues found
  • 🟡 Complexity: 2 issues found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

cliffy/commander.py Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
tests/test_examples.py Show resolved Hide resolved
tests/test_examples.py Outdated Show resolved Hide resolved
cliffy/cli.py Outdated Show resolved Hide resolved
examples/generated/db.py Show resolved Hide resolved
jaykv and others added 7 commits August 7, 2024 00:17
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@jaykv jaykv merged commit 7c078e5 into main Aug 7, 2024
12 checks passed
@jaykv jaykv deleted the command-aliases branch August 7, 2024 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant