Skip to content

feat: support --version - #67

Merged
pi0 merged 4 commits into
mainfrom
feat/version
Sep 9, 2023
Merged

pi0 merged 4 commits into
mainfrom
feat/version

Conversation

@Barbapapazes

Copy link
Copy Markdown
Contributor

🔗 Linked issue

fix #66

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR adds, as same as -h / --help option, -v / --version option to show the version, if defined, of the CLI.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@Barbapapazes Barbapapazes self-assigned this Sep 5, 2023
@Barbapapazes Barbapapazes added the enhancement New feature or request label Sep 5, 2023
@Barbapapazes
Barbapapazes requested a review from pi0 September 5, 2023 22:08
@pi0 pi0 changed the title feat: support -v or --version feat: support --version Sep 9, 2023
@pi0

pi0 commented Sep 9, 2023 •

Copy link
Copy Markdown
Member

Thanks for this PR i often needed it as well!

I have made few refactors to keep it simple with only --version support when no other args are provided to reduce chances of conflict with user args (such as -v for --verbose). We can improve this later.

@pi0
pi0 merged commit 4bf355e into main Sep 9, 2023
@pi0
pi0 deleted the feat/version branch September 9, 2023 12:00
@ftzi

ftzi commented Dec 20, 2023 •

Copy link
Copy Markdown

I think it should support -v out of the box. It's much more probable to have -v for version than for --verbose. If the user don't want -v, the user should be able to redefine the version command where this alias isn't defined or is something else.

@ftzi

ftzi commented Dec 21, 2023 •

Copy link
Copy Markdown

Even better, if a command with alias h or v is defined, it overwrites the alias for help and version. I think it would be the best of all worlds.

I can happily make a PR for that. I like this lib, and it's very similar to a solution I did for myself some time ago.

@pi0

pi0 commented Dec 21, 2023

Copy link
Copy Markdown
Member

@SrBrahma can you please open an issue to keep track of this? Auto disable sounds nice idea (BTW, it is not that easy, we need to also scan all sub-commands if they support -v flag for custom behavior or not but seems worth to track)

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.

Missing -v or --version flag

3 participants