You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we generate the completion script for zsh, with the description of the option having a line break, the completion shown is incorrect.
--bar -- Bar option
--foo -- Foo option
--help -- Show help
--version -- Show version number
Should be aligned with foo option The description for foo option
# If you don't enable zsh-completion, you need to enable it first.# Clone and configure repository
$ git clone git@github.com:hung-cybo/yargs-escape-line-break.git
$ cd yargs-escape-line-break
$ npm ci
$ npm run build
$ ./cli.js completion > /path/to/your/fpath/_cli.js
# Reload the shell
In the repository, I specified the options as follows.
yargs.option("foo",{describe: "Foo option\nThe description for foo option\nShould be aligned with foo option",type: "string",}).option("bar",{describe: "Bar option",type: "string",}).completion().help().argv;
With the line break, the option --help display the description easier to read.
Options:
--version Show version number [boolean]
--foo Foo option
The description for foo option
Should be aligned with foo option [string]
--bar Bar option [string]
--help Show help [boolean]
Expected Behavior
The output when I strike the TAB should be the following.
./cli.js completion #Strike TAB
--bar -B -- Bar option
--foo -F -- Foo option The description for foo option Should be aligned with foo option
--help -- Show help
--version -- Show version number
The line break should be converted to whitespace.
Actual Behavior
The actual output is the following.
The description of --foo option is displayed at the end of the output.
./cli.js completion #Strike TAB
-- values --
--bar -- Bar option
--foo -- Foo option
--help -- Show help
--version -- Show version number
Should be aligned with foo option The description for foo option
Cause
When requesting a completion by striking the TAB key, the completion function calls the original file with --get-yargs-completions option.
It is specified in the completion script as follows.
With the current version of yargs, the output is the following.
$ node ./lib/index.js --get-yargs-completions -
--version:Show version number
--foo:Foo option
The description for foo option
Should be aligned with foo option
--bar:Bar option
--help:Show help
The description of --foo option is displayed in multi-lines.
And with the current behavior of zsh-completion, each line will be evaluated:
If It meets the format key:desc => mark it as an option
If It does not meet the format key:desc => move it to the bottom
Therefore, It will be good if we can escape the line break of the description and convert it to whitespace.
The text was updated successfully, but these errors were encountered:
Hi! 馃憢
Firstly, thanks for your work on this project! 馃檪
This is a feature request.
Environment
Summary
When we generate the completion script for zsh, with the description of the option having a line break, the completion shown is incorrect.
Reproduction
The minimum reproduction in https://github.com/hung-cybo/yargs-escape-line-break
In the repository, I specified the options as follows.
With the line break, the option
--help
display the description easier to read.Expected Behavior
The output when I strike the TAB should be the following.
The line break should be converted to whitespace.
Actual Behavior
The actual output is the following.
The description of
--foo
option is displayed at the end of the output.Cause
When requesting a completion by striking the TAB key, the completion function calls the original file with
--get-yargs-completions
option.It is specified in the completion script as follows.
With the current version of yargs, the output is the following.
The description of
--foo
option is displayed in multi-lines.And with the current behavior of zsh-completion, each line will be evaluated:
key:desc
=> mark it as an optionkey:desc
=> move it to the bottomTherefore, It will be good if we can escape the line break of the description and convert it to whitespace.
The text was updated successfully, but these errors were encountered: