Skip to content

Add -version option to get just the version#4281

Merged
laanwj merged 4 commits intobitcoin:masterfrom
laanwj:2014_06_version_option
Jun 12, 2014
Merged

Add -version option to get just the version#4281
laanwj merged 4 commits intobitcoin:masterfrom
laanwj:2014_06_version_option

Conversation

@laanwj
Copy link
Copy Markdown
Member

@laanwj laanwj commented Jun 3, 2014

Adds a -version or --version option to print just the version of the program for bitcoind, bitcoin-cli and bitcoin-qt (almost every program on linux supports this, I've made the mistake of calling bitcoind with --version multiple times already, before deciding to finally add it).

Also make it that -help can be used to display the help (as well as existing --help). Up to now, -help was the only option that didn't work with either one or two dashes.

Edit: maybe it's a good idea to add license information as well (for example, ls does this too) as print the versions for dependency libraries such as OpenSSL, that would fix #1930.

@laanwj laanwj added this to the 0.10.0 milestone Jun 3, 2014
@jgarzik
Copy link
Copy Markdown
Contributor

jgarzik commented Jun 3, 2014

No objection... the traditional impl of this

  1. prints version on first line of stdout
  2. perhaps prints a copyright
  3. exits without doing anything further
jgarzik@pum:~$ cp --version
cp (GNU coreutils) 8.21
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjörn Granlund, David MacKenzie, and Jim Meyering.
jgarzik@pum:~$ 

kostaz added a commit to kostaz/bitcoin that referenced this pull request Jun 4, 2014
Should be merged after pull request bitcoin#4281
("Add `-version` option to get just the version bitcoin#4281"),
because is changed "--help" to "-help".

Checked that grep of 'mapArgs.count("--' returned only
three places that are fixed by pull request bitcoin#4281.
@laanwj
Copy link
Copy Markdown
Member Author

laanwj commented Jun 4, 2014

I noticed that the -version output was starting to look a lot like the text in the About dialog. To save on translation messages, I unified those texts.

@Diapolo as a byproduct this also solves your remark about #4213, all HTML has been removed from the translation, the links are still clickable by means of a regexp.

@Diapolo
Copy link
Copy Markdown

Diapolo commented Jun 4, 2014

@laanwj That's a good thing, saves us some trouble I guess :).

src/init.cpp Outdated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Diapolo What I don't like about this is splitting the message over multiple translation messages "fragments". I'd prefer to have it one message (as it was with the about box) -- however, you can't rely on translators to insert newlines in the right place. So in that case we'd need an utility function to format it over multiple lines for the terminal. Sounds easy, until you start thinking locales...

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to split out things like the copyright notice or the "this is experimental software" notice. I think the easiest solution for proper newlines is to leave the first two messages seperate and combine the second paragraph into one message and the third paragraph in one message. Then only the two paragraphs need to be properly wordwraped, which is probably supported by some boost function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boost has a function to do word wrapping, but alas it's deeply embedded in boost::program_options https://github.com/mousebird/boost/blob/master/libs/program_options/src/options_description.cpp
Anyhow it shouldn't be too difficult to write one ourselves...

@laanwj
Copy link
Copy Markdown
Member Author

laanwj commented Jun 10, 2014

Ok, I added a FormatParagraph function to resolve my above remark, should be ready for merge now.

@laanwj
Copy link
Copy Markdown
Member Author

laanwj commented Jun 10, 2014

@TheBlueMatt Pulltester is broken, looks like the disk is full.

laanwj added 2 commits June 11, 2014 14:22
Adds a `-version` or `--version` option to print just the version
of the program for bitcoind, bitcoin-cli and bitcoin-qt.

Also make it that `-help` can be used to display the help (as well as
existing `--help`). Up to now, `-help` was the only option that didn't
work with either one or two dashes.
This is to be used for the `-version` and `-help` messages.
@BitcoinPullTester
Copy link
Copy Markdown

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/9ba479a235c7ef57243f5de6538575a101fe03da for binaries and test log.
This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/
Contact BlueMatt on freenode if something looks broken.

@laanwj
Copy link
Copy Markdown
Member Author

laanwj commented Jun 12, 2014

@Diapolo Could you give this a try on windows?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help me, why does this not need to be translated anymore?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's set in the code now.

@Diapolo
Copy link
Copy Markdown

Diapolo commented Jun 12, 2014

Going to try that later :).

src/init.cpp Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: This needs to become return FormatParagraph(strprintf(_("Copyright (C) 2009-%i, The Bitcoin Core Developers"), COPYRIGHT_YEAR)) + "\n\n" + to look really good IMHO :).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the '.', I don't think the ',' between the year and the name makes sense (at least I don't think I've ever seen that before).

@Diapolo
Copy link
Copy Markdown

Diapolo commented Jun 12, 2014

Appart from my nit above ACK!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No , is okay, but you should add another \n as it looks ugly to have the copyright string right before the next sentence (at least that's how it looks for me on Windows).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, added a newline.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but where is it? The ones shown here were there before.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh no, I added one just below here:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just merge, don't ask ^^... ACK².

laanwj added 2 commits June 12, 2014 16:11
Adds a copyright and attribution message to the `-version` output
(the same as shown in the About dialog in the GUI).

Move the message to a function LicenseInfo in init.cpp.
They share so much code and functionality that they may as well
be one class.
@laanwj laanwj merged commit 5c97aae into bitcoin:master Jun 12, 2014
laanwj added a commit that referenced this pull request Jun 12, 2014
5c97aae qt: Unify AboutDialog and HelpMessageDialog (Wladimir J. van der Laan)
45615af Add 'about' information to `-version` output (Wladimir J. van der Laan)
97789d3 util: Add function FormatParagraph to format paragraph to fixed-width (Wladimir J. van der Laan)
96b733e Add `-version` option to get just the version (Wladimir J. van der Laan)
MathyV pushed a commit to reddcoin-project/reddcoin-3.10 that referenced this pull request Nov 3, 2014
Should be merged after pull request bitcoin#4281
("Add `-version` option to get just the version bitcoin#4281"),
because is changed "--help" to "-help".

Checked that grep of 'mapArgs.count("--' returned only
three places that are fixed by pull request bitcoin#4281.
reddink pushed a commit to reddcoin-project/reddcoin-3.10 that referenced this pull request May 27, 2020
Should be merged after pull request bitcoin#4281
("Add `-version` option to get just the version bitcoin#4281"),
because is changed "--help" to "-help".

Checked that grep of 'mapArgs.count("--' returned only
three places that are fixed by pull request bitcoin#4281.

(cherry picked from commit 71aaff3)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copyright and license in the console program, link to the source code, link to the forum discussion

5 participants