Skip to content

Conversation

@lmlsna
Copy link
Contributor

@lmlsna lmlsna commented Nov 15, 2017

This PR would close issue #9195 by adding documentation for the debug console features (mainly nested commands) which were added in PR #7783.

The following changes were made to QT debug console code:

  • Added a line to the initial message text at the top of the debug console:

For more information on using this console type help-console.

  • Added a pseudo-command help-console which is hooked after parsing the request, but before actually executing the RPC thread. It prints the following text to the console as if it were a valid RPC response.

This console accepts RPC commands using the standard syntax.
example: getblockhash 8
This console can also accept RPC commands using bracketed syntax.
example: getblockhash(8)
A space or a comma can be used to separate arguments for either syntax.
example: sendtoaddress <address> <amount>
sendtoaddress,<address>,<amount>
Commands may be nested when specified with the bracketed syntax.
example: getblockinfo(getblockhash(0),true).
Result values can be queried with a non-quoted string in brackets.
example: getblock(getblockhash(0) true)[height]

This seemed like a reasonably sane way to introduce a fake RPC help command, but

" example: getblockinfo(getblockhash(0),true).\n\n"

"Result values can be queried with a non-quoted string in brackets.\n"
" example: getblock(getblockhash(0) true)[height]\n\n" )));
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add an example that uses access-by-index like getblock(getblockhash(0) true)[tx][0]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, should have included that.

Copy link
Member

Choose a reason for hiding this comment

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

Here the use of "bracket" is correct, referring to the [].

@jonasschnelli
Copy link
Contributor

Works as intended.
I think it's not prominent enough,... maybe an icon (unsure) or a clickable text (link) in the console text would make more sense.
At least it should auto-complete help-console when typing in the prompt line.

@lmlsna
Copy link
Contributor Author

lmlsna commented Nov 16, 2017

I figured that it made sense (at least thematically 😅) for console help to be available from the inside the console, but that's basically just my personal preference. I'm guessing the subset of users interested in nested rpc commands are probably more command-line-centric that then the average user. Though a clickable link in the first bit of text might well be a better/cleaner solution.

If kept as a command, I for sure think it should be added to the autocomplete list. I can add that in as well, I just didn't want to go overboard before getting some feedback.

If implemented as a button/link, what should it reference/do? Pop a new window with text (like help > commands) in the file menu?

@laanwj
Copy link
Member

laanwj commented Nov 16, 2017

Thanks for doing this! will test.

@laanwj
Copy link
Member

laanwj commented Nov 16, 2017

I figured that it made sense (at least thematically 😅) for console help to be available from the inside the console,

Agree, I kind of like it as a command. An icon could be added later, but this is what I had in mind. Only have a few comments on the text.

"This console accepts RPC commands using the standard syntax.\n"
" example: getblockhash 8\n\n"

"This console can also accept RPC commands using bracketed syntax.\n"
Copy link
Member

Choose a reason for hiding this comment

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

This is parenthesized not bracketed syntax, I'd say?

"This console can also accept RPC commands using bracketed syntax.\n"
" example: getblockhash(8)\n\n"

"A space or a comma can be used to separate arguments for either syntax.\n"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe "delimit" instead of "separate"?

" example: getblockinfo(getblockhash(0),true).\n\n"

"Result values can be queried with a non-quoted string in brackets.\n"
" example: getblock(getblockhash(0) true)[height]\n\n" )));
Copy link
Member

Choose a reason for hiding this comment

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

Here the use of "bracket" is correct, referring to the [].

message(CMD_REPLY, (tr("Welcome to the %1 RPC console.").arg(tr(PACKAGE_NAME)) + "<br>" +
tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg("<b>"+clsKey+"</b>") + "<br>" +
tr("Type <b>help</b> for an overview of available commands.")) +
tr("Type <b>help</b> for an overview of available commands.<br>") +
Copy link
Member

Choose a reason for hiding this comment

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

Please keep the <br> out of the translation message, as it frequently gets lost by translators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I totally agree with all of this.

@lmlsna
Copy link
Contributor Author

lmlsna commented Nov 16, 2017

I have the autocomplete working and will make the suggested changes to the help text. I'll push a revision today or tomorrow. Thanks for the input guys!

@jonasschnelli
Copy link
Contributor

Thanks! Looks good!
utACK after squash.

@lmlsna
Copy link
Contributor Author

lmlsna commented Nov 17, 2017

squished

@promag
Copy link
Contributor

promag commented Nov 17, 2017

utACK 5305dda.

@jonasschnelli
Copy link
Contributor

utACK 5305dda4c3f2d0b9d6a1bf9d5c4cc1c6215ed475

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

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

utACK 5305dda

Commit message needs modification though, perhaps "Add help-console command to Qt debug console" or something

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not too sure about calling them "numeric result objects", numeric just sounds like it's a type of number, rather than an unnamed list/array or something

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, good point. You think changing those last 2 lines to just "Results can be queried with..." is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change that last bit and resquash with a better commit message.

     - Added `help-console` to the list of autocompletion strings
     - Implemented requested changes to help message:
       - Added an example that uses access-by-index `getblock(getblockhash(0) true)[tx][0]`
       - Replace "bracketed syntax" to "parenthesized syntax" where applicable
       - Replace "separate" with "delimit"
       - Removed `<br>` and `<b>help/help-console</b>` from translation strings, since these parts don't change between languages
       - Changed examples to be based off `getblock 0` so they will work even with pruned/no blockchain and `disablewallet` if copied and pasted
       - Clarified syntax for queries of named/unnamed result objects.
@meshcollider
Copy link
Contributor

re-utACK c3055bb

@laanwj laanwj merged commit c3055bb into bitcoin:master Nov 19, 2017
laanwj added a commit that referenced this pull request Nov 19, 2017
c3055bb Add help-console command to Qt debug console (Luke Mlsna)

Pull request description:

  This PR would close issue #9195 by adding documentation for the debug console features (mainly nested commands) which were added in [PR #7783](#7783).

  The following changes were made to QT debug console code:
  - Added a line to the initial message text at the top of the debug console:

  > For more information on using this console type **help-console**.

  - Added a pseudo-command `help-console` which is hooked after parsing the request, but before actually executing the RPC thread. It prints the following text to the console as if it were a valid RPC response.

  > This console accepts RPC commands using the standard syntax.
  >    example:    getblockhash 8
  > This console can also accept RPC commands using bracketed syntax.
  >    example:    getblockhash(8)
  > A space or a comma can be used to separate arguments for either syntax.
  >    example:    sendtoaddress \<address\> \<amount\>
  >                    sendtoaddress,\<address\>,\<amount\>
  > Commands may be nested when specified with the bracketed syntax.
  >    example:    getblockinfo(getblockhash(0),true).
  > Result values can be queried with a non-quoted string in brackets.
  >    example:    getblock(getblockhash(0) true)[height]

  This seemed like a reasonably sane way to introduce a fake RPC help command, but

Tree-SHA512: 35d73dcef9c4936b8be99e80978169f117c22b94f4400c91097bf7e0e1489060202dcd738d9debdf4c8a7bd10709e2c19d4f625f19e47c4a034f1d6019c0e0f2
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

post merge ACK c3055bb

std::string executableCommand = command.toStdString() + "\n";

// Catch the console-only-help command before RPC call is executed and reply with help text as-if a RPC reply.
if(executableCommand == "help-console\n")
Copy link
Member

@maflcko maflcko Nov 27, 2017

Choose a reason for hiding this comment

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

nit: Should use .starts_with("help-console") to ignore trailing white space. Though, can wait, since that seems to be part of cpp20

Edit: Could use QString::fromStdString(executableCommand).startsWith("help-console")

PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
…ation

c3055bb Add help-console command to Qt debug console (Luke Mlsna)

Pull request description:

  This PR would close issue bitcoin#9195 by adding documentation for the debug console features (mainly nested commands) which were added in [PR bitcoin#7783](bitcoin#7783).

  The following changes were made to QT debug console code:
  - Added a line to the initial message text at the top of the debug console:

  > For more information on using this console type **help-console**.

  - Added a pseudo-command `help-console` which is hooked after parsing the request, but before actually executing the RPC thread. It prints the following text to the console as if it were a valid RPC response.

  > This console accepts RPC commands using the standard syntax.
  >    example:    getblockhash 8
  > This console can also accept RPC commands using bracketed syntax.
  >    example:    getblockhash(8)
  > A space or a comma can be used to separate arguments for either syntax.
  >    example:    sendtoaddress \<address\> \<amount\>
  >                    sendtoaddress,\<address\>,\<amount\>
  > Commands may be nested when specified with the bracketed syntax.
  >    example:    getblockinfo(getblockhash(0),true).
  > Result values can be queried with a non-quoted string in brackets.
  >    example:    getblock(getblockhash(0) true)[height]

  This seemed like a reasonably sane way to introduce a fake RPC help command, but

Tree-SHA512: 35d73dcef9c4936b8be99e80978169f117c22b94f4400c91097bf7e0e1489060202dcd738d9debdf4c8a7bd10709e2c19d4f625f19e47c4a034f1d6019c0e0f2
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request May 11, 2021
d8fe6bf [Doc] Add new GUI RPC-console syntax to release notes (random-zebra)
eced57b Add help-console command to Qt debug console (Luke Mlsna)

Pull request description:

  Follow up to #2282

  First commit backports bitcoin#11698, adding:
  - a line to the initial message text at the top of the debug console
  - a pseudo-command `help-console` which is hooked after parsing the request, but before executing the RPC thread

  Second commit updates the release notes.

ACKs for top commit:
  furszy:
    utACK d8fe6bf
  Fuzzbawls:
    ACK d8fe6bf

Tree-SHA512: df415a27acb587535dfdc8775bacb231d435566bdfb18ea71863212999cf78d139b9b1eaceead5c573ace5203416d2f9392f9179ccd56b3eda1e2ab9fc3ad772
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants