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

[feature] Include conan --version command in conan --help text #13952

Closed
1 task done
meghfossa opened this issue May 23, 2023 · 5 comments · Fixed by #13999
Closed
1 task done

[feature] Include conan --version command in conan --help text #13952

meghfossa opened this issue May 23, 2023 · 5 comments · Fixed by #13999
Assignees
Milestone

Comments

@meghfossa
Copy link

What is your suggestion?

Hi,

  1. When I use, conan --help command, I can see help text message around conan --version. Currently, conan --version command is hidden and not documented in help message. This is so, as a user I can identify which conan version I'm using easily.
  2. When I use, conan --version command, I can retrieve version, of conan.
  3. When I use, conan --version json command, I can retrieve machine-readable version, of conan.
  4. When I use, conan --version json command, I can retrieve machine-readable version, of python. This is so, I can easily see which python environment is being used by conan, as this is a field requested when creating a bug report.

Maybe something like this:
conan --help and conan

~/code/sbom (feat/conan-sbom) » conan  --help

Options
--version [FORMAT] Prints conan version in format. Valid format options are: text, json. By default, text is chosen. 

Consumer commands
...

Creator commands
...

Type "conan <command> -h" for help

conan --version

~/code/sbom (feat/conan-sbom) » conan  --version
Conan version 2.0.5

conan --version json

~/code/sbom (feat/conan-sbom) » conan  --version json
{
   "conan": {
       "version": "x.x.x",
    },
   "python": {
       "version": "x.x.x",
   }
}

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this May 23, 2023
@memsharded
Copy link
Member

Hi @meghfossa

Thanks for your suggestion.

However, I think this proposal goes a bit too far. Basically all other tools out there do not implement anything remotely similar. cmake --version, gcc --version, etc, which one is expected to be able to give a json output? None of them. Furthermore, reporting also a sub-tool like Python version in the return is also too much. The expectation for dev tools for xxx --version is outputting some plain text with the version number included plus other details, but not json output.

If you want to control the Conan version, you have the required_conan_version that you can use both in the recipes and in your global.conf (as core:required_conan_version).

@meghfossa
Copy link
Author

meghfossa commented May 24, 2023

However, I think this proposal goes a bit too far. Basically all other tools out there do not implement anything remotely similar. cmake --version, gcc --version, etc, which one is expected to be able to give a json output? None of them. Furthermore, reporting also a sub-tool like Python version in the return is also too much. The expectation for dev tools for xxx --version is outputting some plain text with the version number included plus other details, but not json output.

That's fair. But I do think including --version command explicitly in help text or even when you just run conan is helpful.

As a additional datapoint, I've added few popular app/pkg-manager that I've come across in past that either include additional attrs (rel dep) or provide machine-readable formatting.

>> cargo version -vv
cargo 1.64.0 (387270bc7 2022-09-16)
release: 1.64.0
commit-hash: 387270bc7f446d17869c7f208207c73231d6a252
commit-date: 2022-09-16
host: x86_64-apple-darwin
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.87.0 (sys:0.4.55+curl-7.83.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.3.0 [64-bit]

>> npm version
{
  npm: '9.5.0',
  node: '18.15.0',
  v8: '10.2.154.26-node.25',
  uv: '1.44.2',
  zlib: '1.2.13',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '108',
  nghttp2: '1.51.0',
  napi: '8',
  llhttp: '6.0.10',
  uvwasi: '0.0.15',
  acorn: '8.8.2',
  simdutf: '3.1.0',
  undici: '5.20.0',
  openssl: '3.0.8+quic',
  cldr: '42.0',
  icu: '72.1',
  tz: '2022g',
  unicode: '15.0',
  ngtcp2: '0.8.1',
  nghttp3: '0.7.0'
}

>> docker version --format json
{....}

>> podman version --format json
{....}

>> gradle --version
------------------------------------------------------------
Gradle 8.1.1
------------------------------------------------------------

Build time:   2023-04-21 12:31:26 UTC
Revision:     1cf537a851c635c364a4214885f8b9798051175b

Kotlin:       1.8.10
Groovy:       3.0.15
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          17.0.7 (Homebrew 17.0.7+0)
OS:           Mac OS X 13.3 aarch64
>> ...

@memsharded
Copy link
Member

Good point.
Lets re-consider it, but not as --version, that would break the CLI design and make the implementation dirty. We can consider a conan version --format=json command.

@memsharded
Copy link
Member

Lets go for it, lets do it

@memsharded
Copy link
Member

Implemented in #13999 for 2.0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants