Add URI info into -help output #227

pull hebasto wants to merge 1 commits into bitcoin-core:master from hebasto:210224-help changing 4 files +14 −7
  1. hebasto commented at 6:47 pm on February 24, 2021: member

    When wallet is enabled -help shows the info about passing an URI to the bitcoin-qt:

     0$ src/qt/bitcoin-qt -? | head
     1Bitcoin Core version v21.99.0-82f37decdbba
     2
     3Usage:  bitcoin-qt [options] [URI]
     4
     5URI must follow BIP 21
     6
     7Options:
     8
     9  -?
    10       Print this help message and exit
    

    Screenshot from 2021-02-24 20-47-00

  2. jarolrod commented at 6:56 pm on February 24, 2021: member

    ACK 82f37decdbba340ea9798e0c82ae7b3cc4100248

    I did not know you can provide a URI when running bitcoin-qt, so this is definitely helpful information.

    One thing is that it would leave the user wondering if they aren’t already aware, “what is BIP 21?” An internet search suffices, but what If a hyper-link was used?

  3. hebasto commented at 8:03 pm on February 24, 2021: member

    … what If a hyper-link was used?

    Not sure if it is worth to add complexity, but I will do it if there will be reviewers’ consensus.

  4. in src/qt/bitcoin.cpp:513 in 82f37decdb outdated
    509@@ -510,7 +510,11 @@ int GuiMain(int argc, char* argv[])
    510     // Show help message immediately after parsing command-line options (for "-lang") and setting locale,
    511     // but before showing splash screen.
    512     if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
    513-        HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version"));
    514+        bool wallet_enabled{false};
    


    Talkless commented at 6:40 pm on February 25, 2021:

    nit: welp, we could go full const by using complete set of #ifdef / #else / #endif:

    0#ifdef ENABLE_WALLET
    1        const bool wallet_enabled{WalletModel::isWalletEnabled()};
    2#else
    3        constexpr bool wallet_enabled{false};
    4#endif // ENABLE_WALLET
    

    hebasto commented at 4:22 pm on February 26, 2021:
    Thanks! Updated.
  5. in src/qt/utilitydialog.h:25 in 82f37decdb outdated
    21@@ -22,7 +22,7 @@ class HelpMessageDialog : public QDialog
    22     Q_OBJECT
    23 
    24 public:
    25-    explicit HelpMessageDialog(QWidget *parent, bool about);
    26+    explicit HelpMessageDialog(QWidget *parent, bool about, bool wallet_enabled = true);
    


    Talkless commented at 6:48 pm on February 25, 2021:

    Not sure if we need = true default. HelpMessageDialog is not something that is used a lot (only twice?), and if it was, assuming = true as default would probably be error prone, as it has to actually depend on the build.

    Also, bitcoingui.h has bool enableWallet = false; defined, so at least it’s inconsistency.


    hebasto commented at 7:12 pm on February 25, 2021:
    btw, I think that combining two independent dialogs in one widget is a bad implementation. I mean about parameter.

    hebasto commented at 4:22 pm on February 26, 2021:
  6. in src/qt/utilitydialog.cpp:62 in 82f37decdb outdated
    57@@ -58,7 +58,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
    58         ui->helpMessage->setVisible(false);
    59     } else {
    60         setWindowTitle(tr("Command-line options"));
    61-        QString header = "Usage:  bitcoin-qt [command-line options]                     \n";
    62+        const QString uri_info = wallet_enabled ? QStringLiteral(" [URI]\n\nURI must follow BIP 21") : QString();
    63+        const QString header(QLatin1String("Usage:  bitcoin-qt [options]") + uri_info + QLatin1Char('\n'));
    


    Talkless commented at 6:48 pm on February 25, 2021:

    nit: well, if care was taken to use lean QLatin1String, including <QStringBuilder> and using % instead of + would make it even beter. Using QStringBuilder avoids that quadratic re-copying of string buffer with every +.

    https://wiki.qt.io/Using_QString_Effectively#QStringBuilder_:_Fast_QString_concatenation

    https://doc.qt.io/qt-5/qstring.html#more-efficient-string-construction


    hebasto commented at 4:22 pm on February 26, 2021:
  7. Talkless changes_requested
  8. Talkless commented at 6:54 pm on February 25, 2021: none
    Concept ACK
  9. qt: Add URI info into -help output 0135c2a1f0
  10. hebasto force-pushed on Feb 26, 2021
  11. hebasto commented at 4:21 pm on February 26, 2021: member

    Updated 82f37decdbba340ea9798e0c82ae7b3cc4100248 -> 0135c2a1f05f64522de9a00cdfa1c33fe668a0bb (pr227.01 -> pr227.02, diff):

  12. in src/qt/bitcoin.cpp:514 in 0135c2a1f0
    509@@ -510,7 +510,12 @@ int GuiMain(int argc, char* argv[])
    510     // Show help message immediately after parsing command-line options (for "-lang") and setting locale,
    511     // but before showing splash screen.
    512     if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
    513-        HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version"));
    514+#ifdef ENABLE_WALLET
    515+        const bool wallet_enabled{WalletModel::isWalletEnabled()};
    


    luke-jr commented at 4:18 pm on February 27, 2021:
    Whether this running instance has the wallet disabled at runtime or not is irrelevant to a new execution… Can fold the #ifdef deep into utilitydialog.cpp

    Talkless commented at 2:55 pm on February 28, 2021:
    @luke-jr you mean that there’s no need for HelpMessageDialog to have that third constructor argument at all? It could decide in it’s implementation if wallet is compiled or not?

    luke-jr commented at 4:43 pm on February 28, 2021:
    Correct. The help message is about the build, not the current runtime.

    Talkless commented at 4:45 pm on March 11, 2021:
    Ping @hebasto , @luke-jr has a point, or will your argue that run time (not compile time) changes should change help too?
  13. luke-jr changes_requested
  14. in src/qt/utilitydialog.h:25 in 0135c2a1f0
    21@@ -22,7 +22,7 @@ class HelpMessageDialog : public QDialog
    22     Q_OBJECT
    23 
    24 public:
    25-    explicit HelpMessageDialog(QWidget *parent, bool about);
    26+    explicit HelpMessageDialog(QWidget* parent, bool about, bool wallet_enabled = false);
    


    Talkless commented at 12:29 pm on February 28, 2021:

    I see default changed to = false, but do we really need it (default value) at all?

    I mean, why some “abstract” user of this class would allow himself to skip passing explicit argument and let default be assumed as false? Maybe there’s argument for it and I am missing it.


    hebasto commented at 12:34 pm on February 28, 2021:
    When about is true it does not matter what value wallet_enabled has. It seems weird to choose any its value on the caller site.

    Talkless commented at 2:35 pm on February 28, 2021:
    Oh, so it depends on about too. OK got it.
  15. in src/qt/utilitydialog.cpp:62 in 0135c2a1f0
    58@@ -58,7 +59,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
    59         ui->helpMessage->setVisible(false);
    60     } else {
    61         setWindowTitle(tr("Command-line options"));
    62-        QString header = "Usage:  bitcoin-qt [command-line options]                     \n";
    63+        const QString uri_info = wallet_enabled ? QStringLiteral(" [URI]\n\nURI must follow BIP 21") : QString();
    


    jarolrod commented at 4:11 am on March 4, 2021:

    The URI has to be enclosed in single/double quotation marks. Maybe this should be added to avoid people wondering why they get to an exit message in their terminal.

    0        const QString uri_info = wallet_enabled ? QStringLiteral(" ["URI"]\n\nURI must follow BIP 21") : QString();
    
  16. hebasto commented at 10:04 pm on May 10, 2021: member
    Closing and leaving it up for grabs.
  17. hebasto closed this on May 10, 2021

  18. hebasto added the label Doc on May 10, 2021
  19. hebasto added the label up for grabs on May 10, 2021
  20. bitcoin-core locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-01 02:20 UTC

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