Add `-version` option to get just the version #4281

pull laanwj wants to merge 4 commits into bitcoin:master from laanwj:2014_06_version_option changing 14 files +155 −311
  1. laanwj commented at 2:20 PM on June 3, 2014: member

    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.

  2. laanwj added this to the milestone 0.10.0 on Jun 3, 2014
  3. jgarzik commented at 4:14 PM on June 3, 2014: contributor

    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:~$ 
    
  4. kostaz referenced this in commit 71aaff393f on Jun 4, 2014
  5. laanwj commented at 4:49 PM on June 4, 2014: member

    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.

  6. Diapolo commented at 7:13 PM on June 4, 2014: none

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

  7. in src/init.cpp:None in f5abc7dfe5 outdated
     327 | +            _("Distributed under the MIT/X11 software license, see the accompanying file") + "\n" +
     328 | +            _("COPYING or <http://www.opensource.org/licenses/mit-license.php>.") + "\n" +
     329 | +            "\n" +
     330 | +            _("This product includes software developed by the OpenSSL Project for use in the") + "\n" +
     331 | +            _("OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software written") + "\n" +
     332 | +            _("by Eric Young and UPnP software written by Thomas Bernard.") + "\n";
    


    laanwj commented at 6:53 AM on June 5, 2014:

    @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...


    leofidus commented at 12:54 AM on June 7, 2014:

    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.


    laanwj commented at 10:57 AM on June 9, 2014:

    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...

  8. laanwj commented at 2:08 PM on June 10, 2014: member

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

  9. laanwj commented at 2:24 PM on June 10, 2014: member

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

  10. Add `-version` option to get just the version
    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.
    96b733e996
  11. util: Add function FormatParagraph to format paragraph to fixed-width
    This is to be used for the `-version` and `-help` messages.
    97789d374c
  12. BitcoinPullTester commented at 8:19 PM on June 11, 2014: none

    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.

  13. laanwj commented at 3:55 AM on June 12, 2014: member

    @diapolo Could you give this a try on windows?

  14. in src/qt/forms/helpmessagedialog.ui:None in 9ba479a235 outdated
      15 | @@ -16,7 +16,7 @@
      16 |     </font>
      17 |    </property>
      18 |    <property name="windowTitle">
      19 | -   <string>Bitcoin Core - Command-line options</string>
      20 | +   <string notr="true">Bitcoin Core - Command-line options</string>
    


    Diapolo commented at 6:36 AM on June 12, 2014:

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


    laanwj commented at 6:38 AM on June 12, 2014:

    Because it's set in the code now.

  15. in src/qt/forms/helpmessagedialog.ui:None in 9ba479a235 outdated
      53 | @@ -54,11 +54,6 @@
      54 |          <layout class="QVBoxLayout" name="verticalLayout_2">
      55 |           <item>
      56 |            <widget class="QLabel" name="helpMessageLabel">
      57 | -           <property name="font">
      58 | -            <font>
      59 | -             <family>Terminal</family>
    


    Diapolo commented at 6:37 AM on June 12, 2014:

    And why do you remove that font? I added it, because of the even lines, which honor our formatting.

    Edit: Ahh, because of FormatParagraph()...


    laanwj commented at 6:39 AM on June 12, 2014:

    It's set in the code, depending on the mode:

    ui->helpMessageLabel->setFont(GUIUtil::bitcoinAddressFont());
    
  16. Diapolo commented at 6:39 AM on June 12, 2014: none

    Going to try that later :).

  17. in src/init.cpp:None in 9ba479a235 outdated
     328 | @@ -330,6 +329,17 @@ std::string HelpMessage(HelpMessageMode hmm)
     329 |      return strUsage;
     330 |  }
     331 |  
     332 | +std::string LicenseInfo()
     333 | +{
     334 | +    return FormatParagraph(strprintf(_("Copyright (C) 2009-%i The Bitcoin Core Developers."), COPYRIGHT_YEAR)) + "\n" +
    


    Diapolo commented at 1:04 PM on June 12, 2014:

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


    laanwj commented at 1:20 PM on June 12, 2014:

    Sure


    laanwj commented at 1:53 PM on June 12, 2014:

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

  18. Diapolo commented at 1:19 PM on June 12, 2014: none

    Appart from my nit above ACK!

  19. Add 'about' information to `-version` output
    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.
    45615af26f
  20. qt: Unify AboutDialog and HelpMessageDialog
    They share so much code and functionality that they may as well
    be one class.
    5c97aae6da
  21. in src/init.cpp:None in fbaecae6b4 outdated
     328 | @@ -330,6 +329,17 @@ std::string HelpMessage(HelpMessageMode hmm)
     329 |      return strUsage;
     330 |  }
     331 |  
     332 | +std::string LicenseInfo()
     333 | +{
     334 | +    return FormatParagraph(strprintf(_("Copyright (C) 2009-%i The Bitcoin Core Developers"), COPYRIGHT_YEAR)) + "\n" +
    


    Diapolo commented at 2:00 PM on June 12, 2014:

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


    laanwj commented at 2:18 PM on June 12, 2014:

    Ok, added a newline.


    Diapolo commented at 2:29 PM on June 12, 2014:

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


    laanwj commented at 2:32 PM on June 12, 2014:

    sigh no, I added one just below here:


    Diapolo commented at 2:38 PM on June 12, 2014:

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

  22. laanwj merged this on Jun 12, 2014
  23. laanwj closed this on Jun 12, 2014

  24. laanwj referenced this in commit fe1f417287 on Jun 12, 2014
  25. MathyV referenced this in commit 171e38f9be on Nov 3, 2014
  26. reddink referenced this in commit aad2536225 on May 27, 2020
  27. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me