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

Add ansible-community version CLI tool #429

Merged
merged 9 commits into from
Jun 7, 2022

Conversation

felixfontein
Copy link
Collaborator

@mariolenz
Copy link

@felixfontein How is ansible-community packaged as a command that someone can execute? Looks like magic to me, I don't really understand it.

Does this happen through console_scripts in entry_points in src/antsibull/data/ansible-setup_py.j2?

@felixfontein
Copy link
Collaborator Author

@mariolenz yes, the entrypoint makes sure pip creates a CLI program called ansible-community that runs the main() from ansible_collections.ansible_community.

@felixfontein
Copy link
Collaborator Author

This is now being voted on in ansible-community/community-topics#107. If the proposal is accepted, this will get merged by next week Tuesday and will be used for the Ansible 6.0.0b3 release.

@felixfontein
Copy link
Collaborator Author

Hmm, I just noticed that there is no 6.0.0b3 release, the release next week is 6.0.0rc1.

@samccann
Copy link
Contributor

samccann commented Jun 1, 2022

@felixfontein so from the user perspective, I do :
pip install ansible

And as part of that, I get a new CLI command called ansible-community that has only one parameter so far for:
ansible-community --version

Is that correct?

From the docs perspective, we need a good place to document this. The rest of the Ansible CLI commands have autogenerated docs here - https://github.com/ansible/ansible/blob/devel/docs/docsite/rst/user_guide/command_line_tools.rst. I'm thinking we add a manual file to that list for ansible-community. We'd have to exclude it from the core docs for sure. Thoughts?

@felixfontein
Copy link
Collaborator Author

Is that correct?

Yes, that's correct.

From the docs perspective, we need a good place to document this. The rest of the Ansible CLI commands have autogenerated docs here - https://github.com/ansible/ansible/blob/devel/docs/docsite/rst/user_guide/command_line_tools.rst. I'm thinking we add a manual file to that list for ansible-community.

Sounds good! Eventually we can also try to auto-generate that page, but as a first step a manually created file sounds good.

We'd have to exclude it from the core docs for sure. Thoughts?

I guess we'll have to do the same thing as for the collection-specific dev guides, and the other ansible vs. ansible-core docsite diferences.

help="show the version of the Ansible community package",
)
args = parser.parse_args() # noqa: F841, pylint: disable=unused-variable
parser.print_help()

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.

Copy link
Collaborator Author

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 before parser.print_help() is executed (search for version= 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:).

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 :-)

@samccann
Copy link
Contributor

samccann commented Jun 6, 2022

Is it possible at some point to also add the ansible-core version to the output so a user gets both? Or is that info not available wherever this command runs? Not a holdup for this PR at all, just wanted to ask what's possible for a future enhancement, or if a user will need to type both commands (ansible --version and ansible-community --version) to get the complete picture.

@felixfontein
Copy link
Collaborator Author

@samccann yes, that's definitely possible. (It's just that we wanted to keep the first PR simple so we don't spend some weeks discussing how exactly everything is displayed, and by that miss all deadlines ;-) )

@samccann
Copy link
Contributor

samccann commented Jun 6, 2022

@felixfontein cool thanks!

@felixfontein felixfontein changed the title [WIP] Add ansible-community version CLI tool Add ansible-community version CLI tool Jun 7, 2022
@felixfontein felixfontein merged commit fddcae7 into ansible-community:main Jun 7, 2022
@felixfontein felixfontein deleted the version-cli branch June 7, 2022 10:56
@felixfontein
Copy link
Collaborator Author

@mariolenz thanks for preparing and suggesting this!
@samccann @pilou- thanks for reviewing this!

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.

4 participants