diff options
author | Kate Stone <katherine.stone@apple.com> | 2015-07-14 05:48:36 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2015-07-14 05:48:36 +0000 |
commit | ea671fbdffda6976607997eb2e5d796211cf5003 (patch) | |
tree | 24e6b00951c3ddccba9afad5f20faaf338d8ff81 /lldb/source/Commands/CommandObjectCommands.cpp | |
parent | 2ffb36e829f79d3660b7a2cf94a1746f62a81518 (diff) | |
download | llvm-ea671fbdffda6976607997eb2e5d796211cf5003.zip llvm-ea671fbdffda6976607997eb2e5d796211cf5003.tar.gz llvm-ea671fbdffda6976607997eb2e5d796211cf5003.tar.bz2 |
Fixed line wrapping for the "long help" content in LLDB commands. Content is now dynamically wrapped for the column width of the current terminal. Lines that begin with whitespace will be indented identically on subsequent lines to maintain formatting.
Existing commands supplying this type of help content have been reworked to take advantage of the changes. In addition to formatting changes, content was changes for accuracy and clarity purposes.
<rdar://problem/21269977>
llvm-svn: 242122
Diffstat (limited to 'lldb/source/Commands/CommandObjectCommands.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 171 |
1 files changed, 92 insertions, 79 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 5fd99cf..f56d089 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -450,60 +450,74 @@ public: NULL) { SetHelpLong( - "'alias' allows the user to create a short-cut or abbreviation for long \n\ - commands, multi-word commands, and commands that take particular options. \n\ - Below are some simple examples of how one might use the 'alias' command: \n\ - \n 'command alias sc script' // Creates the abbreviation 'sc' for the 'script' \n\ - // command. \n\ - 'command alias bp breakpoint' // Creates the abbreviation 'bp' for the 'breakpoint' \n\ - // command. Since breakpoint commands are two-word \n\ - // commands, the user will still need to enter the \n\ - // second word after 'bp', e.g. 'bp enable' or \n\ - // 'bp delete'. \n\ - 'command alias bpl breakpoint list' // Creates the abbreviation 'bpl' for the \n\ - // two-word command 'breakpoint list'. \n\ - \nAn alias can include some options for the command, with the values either \n\ - filled in at the time the alias is created, or specified as positional \n\ - arguments, to be filled in when the alias is invoked. The following example \n\ - shows how to create aliases with options: \n\ - \n\ - 'command alias bfl breakpoint set -f %1 -l %2' \n\ - \nThis creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \n\ - options already part of the alias. So if the user wants to set a breakpoint \n\ - by file and line without explicitly having to use the -f and -l options, the \n\ - user can now use 'bfl' instead. The '%1' and '%2' are positional placeholders \n\ - for the actual arguments that will be passed when the alias command is used. \n\ - The number in the placeholder refers to the position/order the actual value \n\ - occupies when the alias is used. All the occurrences of '%1' in the alias \n\ - will be replaced with the first argument, all the occurrences of '%2' in the \n\ - alias will be replaced with the second argument, and so on. This also allows \n\ - actual arguments to be used multiple times within an alias (see 'process \n\ - launch' example below). \n\ - Note: the positional arguments must substitute as whole words in the resultant\n\ - command, so you can't at present do something like:\n\ - \n\ - command alias bcppfl breakpoint set -f %1.cpp -l %2\n\ - \n\ - to get the file extension \".cpp\" automatically appended. For more complex\n\ - aliasing, use the \"command regex\" command instead.\n\ - \nSo in the 'bfl' case, the actual file value will be \n\ - filled in with the first argument following 'bfl' and the actual line number \n\ - value will be filled in with the second argument. The user would use this \n\ - alias as follows: \n\ - \n (lldb) command alias bfl breakpoint set -f %1 -l %2 \n\ - <... some time later ...> \n\ - (lldb) bfl my-file.c 137 \n\ - \nThis would be the same as if the user had entered \n\ - 'breakpoint set -f my-file.c -l 137'. \n\ - \nAnother example: \n\ - \n (lldb) command alias pltty process launch -s -o %1 -e %1 \n\ - (lldb) pltty /dev/tty0 \n\ - // becomes 'process launch -s -o /dev/tty0 -e /dev/tty0' \n\ - \nIf the user always wanted to pass the same value to a particular option, the \n\ - alias could be defined with that value directly in the alias as a constant, \n\ - rather than using a positional placeholder: \n\ - \n command alias bl3 breakpoint set -f %1 -l 3 // Always sets a breakpoint on line \n\ - // 3 of whatever file is indicated. \n"); +"'alias' allows the user to create a short-cut or abbreviation for long \ +commands, multi-word commands, and commands that take particular options. \ +Below are some simple examples of how one might use the 'alias' command:" R"( + +(lldb) command alias sc script + + Creates the abbreviation 'sc' for the 'script' command. + +(lldb) command alias bp breakpoint + +)" " Creates the abbreviation 'bp' for the 'breakpoint' command. Since \ +breakpoint commands are two-word commands, the user would still need to \ +enter the second word after 'bp', e.g. 'bp enable' or 'bp delete'." R"( + +(lldb) command alias bpl breakpoint list + + Creates the abbreviation 'bpl' for the two-word command 'breakpoint list'. + +)" "An alias can include some options for the command, with the values either \ +filled in at the time the alias is created, or specified as positional \ +arguments, to be filled in when the alias is invoked. The following example \ +shows how to create aliases with options:" R"( + +(lldb) command alias bfl breakpoint set -f %1 -l %2 + +)" " Creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \ +options already part of the alias. So if the user wants to set a breakpoint \ +by file and line without explicitly having to use the -f and -l options, the \ +user can now use 'bfl' instead. The '%1' and '%2' are positional placeholders \ +for the actual arguments that will be passed when the alias command is used. \ +The number in the placeholder refers to the position/order the actual value \ +occupies when the alias is used. All the occurrences of '%1' in the alias \ +will be replaced with the first argument, all the occurrences of '%2' in the \ +alias will be replaced with the second argument, and so on. This also allows \ +actual arguments to be used multiple times within an alias (see 'process \ +launch' example below)." R"( + +)" "Note: the positional arguments must substitute as whole words in the resultant \ +command, so you can't at present do something like this to append the file extension \ +\".cpp\":" R"( + +(lldb) command alias bcppfl breakpoint set -f %1.cpp -l %2 + +)" "For more complex aliasing, use the \"command regex\" command instead. In the \ +'bfl' case above, the actual file value will be filled in with the first argument \ +following 'bfl' and the actual line number value will be filled in with the second \ +argument. The user would use this alias as follows:" R"( + +(lldb) command alias bfl breakpoint set -f %1 -l %2 +(lldb) bfl my-file.c 137 + +This would be the same as if the user had entered 'breakpoint set -f my-file.c -l 137'. + +Another example: + +(lldb) command alias pltty process launch -s -o %1 -e %1 +(lldb) pltty /dev/tty0 + + Interpreted as 'process launch -s -o /dev/tty0 -e /dev/tty0' + +)" "If the user always wanted to pass the same value to a particular option, the \ +alias could be defined with that value directly in the alias as a constant, \ +rather than using a positional placeholder:" R"( + +(lldb) command alias bl3 breakpoint set -f %1 -l 3 + + Always sets a breakpoint on line 3 of whatever file is indicated.)" + ); CommandArgumentEntry arg1; CommandArgumentEntry arg2; @@ -960,31 +974,30 @@ public: IOHandlerDelegateMultiline ("", IOHandlerDelegate::Completion::LLDBCommand), m_options (interpreter) { - SetHelpLong( -"This command allows the user to create powerful regular expression commands\n" -"with substitutions. The regular expressions and substitutions are specified\n" -"using the regular expression substitution format of:\n" -"\n" -" s/<regex>/<subst>/\n" -"\n" -"<regex> is a regular expression that can use parenthesis to capture regular\n" -"expression input and substitute the captured matches in the output using %1\n" -"for the first match, %2 for the second, and so on.\n" -"\n" -"The regular expressions can all be specified on the command line if more than\n" -"one argument is provided. If just the command name is provided on the command\n" -"line, then the regular expressions and substitutions can be entered on separate\n" -" lines, followed by an empty line to terminate the command definition.\n" -"\n" -"EXAMPLES\n" -"\n" -"The following example will define a regular expression command named 'f' that\n" -"will call 'finish' if there are no arguments, or 'frame select <frame-idx>' if\n" -"a number follows 'f':\n" -"\n" -" (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/'\n" -"\n" - ); + SetHelpLong(R"( +)" "This command allows the user to create powerful regular expression commands \ +with substitutions. The regular expressions and substitutions are specified \ +using the regular expression substitution format of:" R"( + + s/<regex>/<subst>/ + +)" "<regex> is a regular expression that can use parenthesis to capture regular \ +expression input and substitute the captured matches in the output using %1 \ +for the first match, %2 for the second, and so on." R"( + +)" "The regular expressions can all be specified on the command line if more than \ +one argument is provided. If just the command name is provided on the command \ +line, then the regular expressions and substitutions can be entered on separate \ +lines, followed by an empty line to terminate the command definition." R"( + +EXAMPLES + +)" "The following example will define a regular expression command named 'f' that \ +will call 'finish' if there are no arguments, or 'frame select <frame-idx>' if \ +a number follows 'f':" R"( + + (lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/')" + ); } ~CommandObjectCommandsAddRegex() |