-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add ansible-community version CLI tool #429
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
15c4150
Add CLI program from 6.0.0b3 on.
felixfontein 8783415
Add simple test.
felixfontein 3efd668
Make PypiVer available for version comparisons.
felixfontein 6d3eefc
Simplify comparison.
felixfontein c95a9f9
Add changelog.
felixfontein e4f8ade
Spell test correctly.
felixfontein 384a0ad
Make sure tool passes linting. Also print help if --version is not sp…
felixfontein 0477a3c
There is no 6.0.0b3. The next planned release is 6.0.0rc1.
felixfontein e32049d
Remove the not-used arguments.
felixfontein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- "Include ``ansible-community`` CLI program with ``--version`` parameter from Ansible 6.0.0rc1 on (https://github.com/ansible-community/antsibull/pull/429)." |
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,25 @@ | ||
#!/usr/bin/python | ||
# coding: utf-8 | ||
# Author: Mario Lenz <m@riolenz.de> | ||
# License: GPLv3+ | ||
# Copyright: Ansible Project, 2022 | ||
"""The ansible-community CLI program.""" | ||
|
||
import argparse | ||
|
||
|
||
def main(): | ||
'''Main entrypoint for the ansible-community CLI program.''' | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'--version', | ||
action='version', | ||
version='Ansible community version {{ version }}', | ||
help="show the version of the Ansible community package", | ||
) | ||
parser.parse_args() | ||
parser.print_help() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this always print help? I mean, if someone runs
ansible-communty --version
, why should we print the help message here? There's not much help, anyway, since there's only the--version
at the moment.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
--version
is used, the program exists beforeparser.print_help()
is executed (search forversion=
on https://docs.python.org/3/library/argparse.html:This expects a version= keyword argument in the [add_argument()](https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument) call, and prints version information and exits when invoked:
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining @felixfontein! LGTM :-)