From 01431fbd4bb4f95b5474b073b766bd3e473c9093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Gonz=C3=A1lez=20Prieto?= Date: Fri, 22 Dec 2023 11:51:38 +0100 Subject: [PATCH] Accept option alternatives after "," + 3 spaces Fixes #25 Kind of related to the solution to #22. There, we accepted 2 spaces instead of the most common single space: ", ". This allows for a 3rd space. Some help messages do this to align short and long options, and it doesn't seem to give any false positives, so let's allow it. --- syntaxes/cmd-help.sublime-syntax | 2 +- tests/highlighted/nvidia-smi-470.129.06.txt | 48 ++++++++++----------- tests/syntax/syntax_test_nvidia-smi.txt | 3 +- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/syntaxes/cmd-help.sublime-syntax b/syntaxes/cmd-help.sublime-syntax index a86f128..350a3bf 100644 --- a/syntaxes/cmd-help.sublime-syntax +++ b/syntaxes/cmd-help.sublime-syntax @@ -259,7 +259,7 @@ contexts: set: option-def-alt - match: '\s+(?=-)' set: option-def-alt - - match: ', (?=\S)' + - match: ', {2,3}(?=\S)' set: option-def-alt option-def-alt: diff --git a/tests/highlighted/nvidia-smi-470.129.06.txt b/tests/highlighted/nvidia-smi-470.129.06.txt index cb33441..51946ad 100644 --- a/tests/highlighted/nvidia-smi-470.129.06.txt +++ b/tests/highlighted/nvidia-smi-470.129.06.txt @@ -22,13 +22,13 @@  - All Geforce products, starting with the Kepler architecture nvidia-smi [OPTION1 [ARG1]] [OPTION2 [ARG2]] ... - -h, --help Print usage information and exit. + -h, --help Print usage information and exit.  LIST OPTIONS: - -L, --list-gpus Display a list of GPUs connected to the system. + -L, --list-gpus Display a list of GPUs connected to the system. - -B, --list-excluded-gpus Display a list of excluded GPUs in the system. + -B, --list-excluded-gpus Display a list of excluded GPUs in the system.  SUMMARY OPTIONS: @@ -36,22 +36,22 @@  [plus any of] - -i, --id= Target a specific GPU. - -f, --filename= Log to a specified file, rather than to stdout. - -l, --loop= Probe until Ctrl+C at specified second interval. + -i, --id= Target a specific GPU. + -f, --filename= Log to a specified file, rather than to stdout. + -l, --loop= Probe until Ctrl+C at specified second interval.  QUERY OPTIONS: - -q, --query Display GPU or Unit info. + -q, --query Display GPU or Unit info.  [plus any of] - -u, --unit Show unit, rather than GPU, attributes. - -i, --id= Target a specific GPU or Unit. - -f, --filename= Log to a specified file, rather than to stdout. - -x, --xml-format Produce XML output. + -u, --unit Show unit, rather than GPU, attributes. + -i, --id= Target a specific GPU or Unit. + -f, --filename= Log to a specified file, rather than to stdout. + -x, --xml-format Produce XML output.  --dtd When showing xml output, embed DTD. - -d, --display= Display only selected information: MEMORY, + -d, --display= Display only selected information: MEMORY,  UTILIZATION, ECC, TEMPERATURE, POWER, CLOCK,  COMPUTE, PIDS, PERFORMANCE, SUPPORTED_CLOCKS,  PAGE_RETIREMENT, ACCOUNTING, ENCODER_STATS, @@ -61,7 +61,7 @@  Sampling data with max/min/avg is also returned  for POWER, UTILIZATION and CLOCK display types.  Doesn't work with -u or -x flags. - -l, --loop= Probe until Ctrl+C at specified second interval. + -l, --loop= Probe until Ctrl+C at specified second interval.  -lms, --loop-ms= Probe until Ctrl+C at specified millisecond interval. @@ -95,9 +95,9 @@  [plus any of] - -i, --id= Target a specific GPU or Unit. - -f, --filename= Log to a specified file, rather than to stdout. - -l, --loop= Probe until Ctrl+C at specified second interval. + -i, --id= Target a specific GPU or Unit. + -f, --filename= Log to a specified file, rather than to stdout. + -l, --loop= Probe until Ctrl+C at specified second interval.  -lms, --loop-ms= Probe until Ctrl+C at specified millisecond interval.  DEVICE MODIFICATION OPTIONS: @@ -105,9 +105,9 @@  [any one of]  -pm, --persistence-mode= Set persistence mode: 0/DISABLED, 1/ENABLED - -e, --ecc-config= Toggle ECC support: 0/DISABLED, 1/ENABLED - -p, --reset-ecc-errors= Reset ECC error counts: 0/VOLATILE, 1/AGGREGATE - -c, --compute-mode= Set MODE for compute applications: + -e, --ecc-config= Toggle ECC support: 0/DISABLED, 1/ENABLED + -p, --reset-ecc-errors= Reset ECC error counts: 0/VOLATILE, 1/AGGREGATE + -c, --compute-mode= Set MODE for compute applications:  0/DEFAULT, 1/EXCLUSIVE_PROCESS,  2/PROHIBITED  --gom= Set GPU Operation Mode: @@ -166,16 +166,16 @@  [plus optional] - -i, --id= Target a specific GPU. + -i, --id= Target a specific GPU.  -eow, --error-on-warning Return a non-zero error for warnings.  UNIT MODIFICATION OPTIONS: - -t, --toggle-led= Set Unit LED state: 0/GREEN, 1/AMBER + -t, --toggle-led= Set Unit LED state: 0/GREEN, 1/AMBER  [plus optional] - -i, --id= Target a specific Unit. + -i, --id= Target a specific Unit.  SHOW DTD OPTIONS: @@ -183,8 +183,8 @@  [plus optional] - -f, --filename= Log to a specified file, rather than to stdout. - -u, --unit Show unit, rather than device, DTD. + -f, --filename= Log to a specified file, rather than to stdout. + -u, --unit Show unit, rather than device, DTD.  --debug= Log encrypted debug information to a specified file. diff --git a/tests/syntax/syntax_test_nvidia-smi.txt b/tests/syntax/syntax_test_nvidia-smi.txt index 0488ac5..5840a26 100644 --- a/tests/syntax/syntax_test_nvidia-smi.txt +++ b/tests/syntax/syntax_test_nvidia-smi.txt @@ -30,8 +30,7 @@ nvidia-smi [OPTION1 [ARG1]] [OPTION2 [ARG2]] ... -h, --help Print usage information and exit. # ^^ entity.name.function.option.cmd-help # ^^^ - entity.name.function.option.cmd-help -# ^^^^^^ - entity.name.function.option.cmd-help -#todo: #25 +# ^^^^^^ entity.name.function.option.cmd-help LIST OPTIONS: