Add feature to get specific help #17901

pull emilengler wants to merge 1 commits into bitcoin:master from emilengler:2020-01-get-specific-help changing 10 files +52 −9
  1. emilengler commented at 3:28 PM on January 9, 2020: contributor

    This PR makes it possible to get a more specific help about just one CMD. Example:

    $ bitcoind --help=server
    Bitcoin Core version v0.19.99.0-6fdf7dda6
    
    Usage:  bitcoind [options]                     Start Bitcoin Core
    
      -server
           Accept command line and JSON-RPC commands
    
    

    If no arg was given or the arg doesn't exist, it will return the normal full help.

  2. hebasto commented at 3:35 PM on January 9, 2020: member

    ~0

    #17841 (comment) by @jamesob:

    Not worth the change, additional code. grep -C 3 works decently as-is.

    #17841 (comment) by @jonatack:

    unneeded and non-issue, grepping with -A/B/C flags works well.

  3. practicalswift commented at 4:29 PM on January 9, 2020: contributor

    I'm not aware of any Unix tool with this kind of syntax.

    Is there any precedent for the --help=command syntax in any widely used Unix tool?

    Generally I think we should try to follow well established Unix command-line conventions as much as possible.

    Surprises might be fun in other parts of life, but not when it comes to user interfaces :)

  4. DrahtBot added the label GUI on Jan 9, 2020
  5. DrahtBot added the label Utils/log/libs on Jan 9, 2020
  6. emilengler commented at 6:57 PM on January 9, 2020: contributor

    Is there any precedent for the --help=command syntax in any widely used Unix tool?

    Not in Unix but in Bitcoin Core! The RPC help command works similar

  7. laanwj commented at 7:54 AM on January 10, 2020: member

    =0 on this

    Conceptually I think the idea itself is clever. Currently it simply prints the short description (which is the same as using grep) but there could be a short as well as a more verbose help, only printed on request, for settings.

    I'm not opposed to innovation in command line interfaces (because it's not "UNIX convention"), on the other hand, I'm not sure this is something people will actually use (because indeed, no one expects it) and warrants the extra complexity. I'm also not sure bitcoin core is the place for this kind of innovation and discussion around it.

  8. in src/util/system.cpp:526 in 6fdf7dda68 outdated
     521 | +        return this->GetHelpMessage();
     522 | +
     523 | +    std::pair<std::string, ArgsManager::Arg> command;
     524 | +    bool cmdExists = false;
     525 | +    LOCK(cs_args);
     526 | +    for (const auto& arg_map : m_available_args) {
    


    laanwj commented at 7:55 AM on January 10, 2020:

    Please factor this out to a function to get info for a specified setting name instead of having this loop in-line.


    emilengler commented at 7:33 PM on January 10, 2020:

    What's the point of porting this to a function. It is only used once.


    paymog commented at 5:11 PM on January 11, 2020:

    It helps encapsulate logic by naming a block of code. I don't have strong opinions on this but I think it would be helpful for readers. It looks like this loop is determining if the provided helpName is a valid command name. By naming this block of code it becomes significantly easier to reason about IMO.

  9. in src/util/system.cpp:535 in 6fdf7dda68 outdated
     530 | +                cmdExists = true;
     531 | +                break;
     532 | +            }
     533 | +        }
     534 | +    }
     535 | +    // Return the full help if the command is not existent
    


    laanwj commented at 7:57 AM on January 10, 2020:

    It should be an error IMO if the command is not existent. The "in case of doubt dump the manual in the users face" behavior frequently frustrates me in other software :laughing:

  10. Binh0103 approved
  11. emilengler force-pushed on Jan 10, 2020
  12. emilengler commented at 7:16 PM on January 10, 2020: contributor

    Error with bitcoin-qt have been fixed

  13. emilengler force-pushed on Jan 10, 2020
  14. in src/qt/bitcoin.cpp:486 in 40928f6ae6 outdated
     482 | +        std::string helpArg = gArgs.GetArg("-help", "");
     483 | +        bool specialHelp = false;
     484 | +        if (helpArg == "")
     485 | +            specialHelp = false;
     486 | +        else
     487 | +            specialHelp = true;
    


    paymog commented at 5:04 PM on January 11, 2020:

    can/should this be simplified to bool specialHelp = helpArg != "";?

  15. in src/qt/utilitydialog.h:27 in 40928f6ae6 outdated
      23 | @@ -24,7 +24,7 @@ class HelpMessageDialog : public QDialog
      24 |      Q_OBJECT
      25 |  
      26 |  public:
      27 | -    explicit HelpMessageDialog(interfaces::Node& node, QWidget *parent, bool about);
      28 | +    explicit HelpMessageDialog(interfaces::Node& node, QWidget *parent, bool about, bool specHelp = false);
    


    paymog commented at 5:06 PM on January 11, 2020:

    nit: spec might also be read as specific or specification when a new reader comes into the codebase. I think naming it with the full specialHelp you use in https://github.com/bitcoin/bitcoin/pull/17901/files#diff-8c9d79ba40bf702f01685008550ac100R482 would make it easier on new readers to understand what's going on.

  16. in src/util/system.cpp:530 in 40928f6ae6 outdated
     525 | +    LOCK(cs_args);
     526 | +    for (const auto& arg_map : m_available_args) {
     527 | +        for (auto const& arg : arg_map.second) {
     528 | +            if (arg.first == "-" + helpName) {
     529 | +                command = arg;
     530 | +                cmdExists = true;
    


    paymog commented at 5:13 PM on January 11, 2020:

    do you need cmdExists? Can we check if command was set (in the if statement below) without leaning on this extra variable?


    emilengler commented at 10:18 AM on January 12, 2020:

    I also though about this but I'm not sure about how to do it with such a type

  17. paymog commented at 5:20 PM on January 11, 2020: none

    I agree with @practicalswift that we should stay close to unix style as much as possible. I've seen interfaces of the form cmd help sumbcommand and cmd subcommand --help. I'm not sure if those are unix philosophies but I think there's precedent there. @laanwj what do you perceive as the risk of this extra complexity? I'm still new to the community and am trying to understand how risk/reward tradeoffs are thought about. I understand that this PR adds more complexity but I don't see the complexity as high risk.

  18. Add feature to get specific help a8c1cc1ee3
  19. emilengler force-pushed on Jan 12, 2020
  20. promag commented at 6:45 PM on January 12, 2020: member

    The RPC help command works similar

    Not quite similar, calling just help RPC list all commands, not the whole RPC help.

    Concept NACK, sorry, I believe the user is better served with | less or | grep.

  21. fanquake commented at 1:15 AM on January 14, 2020: member

    Concept ~0. I agree that Bitcoin Core isn't really the place where we need to be "innovating" or doing anything unexpected in regards to command line usage and/or features. As mentioned here and in #17841, there are plenty of ways for a user to extract the help information they'd like without adding additional complexity to the codebase.

  22. emilengler commented at 5:18 PM on January 14, 2020: contributor

    Will close this, lost motivation on it

  23. emilengler closed this on Jan 14, 2020

  24. DrahtBot locked this on Feb 15, 2022

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:14 UTC

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