@@ -34,49 +34,36 @@ func NewCmdSet(f *cmdutil.Factory, runF func(*SetOptions) error) *cobra.Command
3434 Use : "set <alias> <expansion>" ,
3535 Short : "Create a shortcut for a gh command" ,
3636 Long : heredoc .Doc (`
37- Declare a word as a command alias that will expand to the specified command(s) .
37+ Define a word that will expand to a full gh command when invoked .
3838
39- The expansion may specify additional arguments and flags. If the expansion
40- includes positional placeholders such as '$1', '$2', etc., any extra arguments
41- that follow the invocation of an alias will be inserted appropriately.
42- Reads from STDIN if '-' is specified as the expansion parameter. This can be useful
43- for commands with mixed quotes or multiple lines.
39+ The expansion may specify additional arguments and flags. If the expansion includes
40+ positional placeholders such as "$1", extra arguments that follow the alias will be
41+ inserted appropriately. Otherwise, extra arguments will be appended to the expanded
42+ command.
4443
45- If '--shell' is specified, the alias will be run through a shell interpreter (sh). This allows you
46- to compose commands with '|' or redirect with '>'. Note that extra arguments following the alias
47- will not be automatically passed to the expanded expression. To have a shell alias receive
48- arguments, you must explicitly accept them using '$1', '$2', etc., or '$@' to accept all of them.
44+ Use "-" as expansion argument to read the expansion string from standard input. This
45+ is useful to avoid quoting issues when defining expansions.
4946
50- Quotes must always be used when defining a command as in the examples unless you pass '-'
51- as the expansion parameter and pipe your command to 'gh alias set'.
52-
53- Platform notes for Windows:
54-
55- - If you are using the Command Prompt (cmd.exe), use *double* quotes instead of single quotes.
56- For instance, use` + " `gh alias set pv \" pr view\" ` instead of `gh alias set pv 'pr view'`. " ),
47+ If the expansion starts with "!" or if "--shell" was given, the expansion is a shell
48+ expression that will be evaluated through the "sh" interpreter when the alias is
49+ invoked. This allows for chaining multiple commands via piping and redirection.
50+ ` ),
5751 Example : heredoc .Doc (`
52+ # note: Command Prompt on Windows requires using double quotes for arguments
5853 $ gh alias set pv 'pr view'
59- $ gh pv -w 123
60- #=> gh pr view -w 123
54+ $ gh pv -w 123 #=> gh pr view -w 123
6155
62- $ gh alias set bugs 'issue list --label=" bugs" '
56+ $ gh alias set bugs 'issue list --label=bugs'
6357 $ gh bugs
6458
6559 $ gh alias set homework 'issue list --assignee @me'
6660 $ gh homework
6761
6862 $ gh alias set epicsBy 'issue list --author="$1" --label="epic"'
69- $ gh epicsBy vilmibm
70- #=> gh issue list --author="vilmibm" --label="epic"
71-
72- $ gh alias set --shell igrep 'gh issue list --label="$1" | grep $2'
73- $ gh igrep epic foo
74- #=> gh issue list --label="epic" | grep "foo"
63+ $ gh epicsBy vilmibm #=> gh issue list --author="vilmibm" --label="epic"
7564
76- # users.txt contains multiline 'api graphql -F name="$1" ...' with mixed quotes
77- $ gh alias set users - < users.txt
78- $ gh users octocat
79- #=> gh api graphql -F name="octocat" ...
65+ $ gh alias set --shell igrep 'gh issue list --label="$1" | grep "$2"'
66+ $ gh igrep epic foo #=> gh issue list --label="epic" | grep "foo"
8067 ` ),
8168 Args : cobra .ExactArgs (2 ),
8269 RunE : func (cmd * cobra.Command , args []string ) error {
0 commit comments