diff --git a/src/DumpCommand.php b/src/DumpCommand.php index d15ca46..137f98c 100644 --- a/src/DumpCommand.php +++ b/src/DumpCommand.php @@ -94,6 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $xmlCommands = $process->getOutput(); + $sanitisedXmlCommands = preg_replace('/\x1b\[[0-9;]*m/', '', $xmlCommands); $xml = simplexml_load_string($xmlCommands); $commands = array(); diff --git a/tests/fixtures/acme b/tests/fixtures/acme index 3d4ff5b..734aaa1 100755 --- a/tests/fixtures/acme +++ b/tests/fixtures/acme @@ -13,6 +13,7 @@ $command1 ->setDefinition(array( new InputOption('dangerous-option', null, InputOption::VALUE_REQUIRED, 'This $hould be `escaped`.'), new InputOption('option-without-description'), + new InputOption('option-with-ansi-codes', null, InputOption::VALUE_NONE, 'I am GREEN!'), )) ; diff --git a/tests/fixtures/bash/cached.txt b/tests/fixtures/bash/cached.txt index 89a4031..987b49f 100644 --- a/tests/fixtures/bash/cached.txt +++ b/tests/fixtures/bash/cached.txt @@ -26,7 +26,7 @@ _acme() case "$com" in hello) - opts="${opts} --dangerous-option --option-without-description" + opts="${opts} --dangerous-option --option-without-description --option-with-ansi-codes" ;; help) diff --git a/tests/fixtures/fish/cached.txt b/tests/fixtures/fish/cached.txt index 7635bb9..6f4854f 100644 --- a/tests/fixtures/fish/cached.txt +++ b/tests/fixtures/fish/cached.txt @@ -27,6 +27,7 @@ complete -c acme -f -n '__fish_acme_no_subcommand' -a command:with:colons -d '' # hello complete -c acme -A -n '__fish_seen_subcommand_from hello' -l dangerous-option -d 'This $hould be `escaped`.' complete -c acme -A -n '__fish_seen_subcommand_from hello' -l option-without-description -d '' +complete -c acme -A -n '__fish_seen_subcommand_from hello' -l option-with-ansi-codes -d 'I am GREEN!' # help complete -c acme -A -n '__fish_seen_subcommand_from help' -l xml -d 'To output help as XML' diff --git a/tests/fixtures/zsh/cached.txt b/tests/fixtures/zsh/cached.txt index 3fe5e4a..b123ffe 100644 --- a/tests/fixtures/zsh/cached.txt +++ b/tests/fixtures/zsh/cached.txt @@ -30,7 +30,7 @@ _acme() case "$com" in hello) - opts+=("--dangerous-option:This \$hould be \`escaped\`." "--option-without-description") + opts+=("--dangerous-option:This \$hould be \`escaped\`." "--option-without-description" "--option-with-ansi-codes:I am GREEN!") ;; help)