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

Conflicting --version option when using default command #510

Closed
SmileyChris opened this issue May 7, 2023 · 6 comments
Closed

Conflicting --version option when using default command #510

SmileyChris opened this issue May 7, 2023 · 6 comments

Comments

@SmileyChris
Copy link
Contributor

Towncrier's build command is the default command, but it uses a custom --version option that collides with the base cli --version option that simply returns the towncrier version number.

> towncrier --version x.y --draft
towncrier, version 22.12.1.dev0
> towncrier build --version x.y --draft
[renders draft newsfile]

I don't really know if there's an easy out. Maybe just don't use any default command (since there's discussion about not having that as a separate dependency anyway: #506)?

@adiroiban
Copy link
Member

I think that it works as expected

I checked a few other tools

$ python3 --version bla
Python 3.10.6
$ tox --version bla
3.21.4 imported from /usr/lib/python3/dist-packages/tox/__init__.py

We had this issue #344
and this PR #341


Can you please specify what is the actual result and what is the expected result?

Thanks

@SmileyChris
Copy link
Contributor Author

We have a custom --version option for the build command that is required to specify the version you're build the news for (to either override a version specified in your toml file, or if none exists this is required -- see also #507 )

@click.option(
"--version",
"project_version",
default=None,
help="Render the news fragments using given version.",
)

If build is the default command, it becomes partially gimped because you can't use this option when (i.e. calling towncrier --version x.y), as it is overridden by click's default --version option (returning the version number, similar to python and tox).

@adiroiban
Copy link
Member

Thanks for the update Chris. It is still not clear what is your expected behaviour.

I think that this is the current behaviour and my expected behaviour.

  • towncrier --version ANYTHONG just return towncrier's own version and ignore any other commands
  • towncrier build --version 1.2 - build the release notes for your project that is now at version 1.2.

What is your expected result for these 2 commands?

@hynek
Copy link
Member

hynek commented May 8, 2023

I agree with Adi here: it's an expectation from a CLI tool to return its own version when passing --version. If anything by it's unfortunate that we have an version flag but it's like with e.g. --help and git: it applies to the active command.

@SmileyChris
Copy link
Contributor Author

SmileyChris commented May 8, 2023

The cli doc's state that

build is also assumed if no command is passed.

So I'll just put a PR for documenting that (build's) --version requires the build command to be explicitly passed.

SmileyChris added a commit to SmileyChris/towncrier that referenced this issue May 8, 2023
SmileyChris added a commit to SmileyChris/towncrier that referenced this issue May 8, 2023
@adiroiban
Copy link
Member

I see... Regarding "build" implicit behavior. I think it's a best effort.

I would prefer not to have a default command... but for towncrier, I think it's too late.
So we just document the current behaviour.

And maybe in the documentation ,we can encourage people to always use an explicit command.

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

No branches or pull requests

3 participants