Skip to content

Commit 497d3b0

Browse files
committed
Bash and fish completion for stg email --git-opts
1 parent 1db5387 commit 497d3b0

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/cmd/completion/bash.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ fn insert_compreply(script: &mut ShStream, arg: &clap::Arg) {
219219
"diff-opts" => {
220220
script.line("mapfile -t COMPREPLY < <(compgen -W \"$(_diff_opts)\" -- \"$cur\")")
221221
}
222+
"git-format-patch-opts" => script
223+
.line("mapfile -t COMPREPLY < <(compgen -W \"$(_format_patch_opts)\" -- \"$cur\")"),
224+
"git-send-email-opts" => script
225+
.line("mapfile -t COMPREPLY < <(compgen -W \"$(_send_email_opts)\" -- \"$cur\")"),
222226
"patch" => script
223227
.line("mapfile -t COMPREPLY < <(compgen -W \"$(_visible_patches)\" -- \"$cur\")"),
224228
"patchranges" => script.line("_patch_range \"$(_visible_patches)\""),
@@ -565,6 +569,16 @@ _diff_opts ()
565569
__git diff-tree --git-completion-helper
566570
}
567571
572+
_format_patch_opts ()
573+
{
574+
__git format-patch --git-completion-helper
575+
}
576+
577+
_send_email_opts()
578+
{
579+
__git send-email --git-completion-helper
580+
}
581+
568582
"#;
569583

570584
const MAIN: &str = r#"

src/cmd/completion/fish.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,24 @@ function __fish_stg_mail_aliases
174174
| cut -d. -f 3
175175
end
176176
177-
function __fish_stg_diff_opts
177+
function __fish_stg_git_diff_opts
178178
__fish_stg_git diff-tree --git-completion-helper \
179179
| string split ' ' \
180180
| string match --regex '\--.+'
181181
end
182182
183+
function __fish_stg_git_format_patch_opts
184+
__fish_stg_git format-patch --git-completion-helper \
185+
| string split ' ' \
186+
| string match --regex '\--.+'
187+
end
188+
189+
function __fish_stg_git_send_email_opts
190+
__fish_stg_git send-email --git-completion-helper \
191+
| string split ' ' \
192+
| string match --regex '\--.+'
193+
end
194+
183195
complete -c stg -n __fish_stg_needs_command -xa '(stg completion list commands-and-aliases --style=fish)'
184196
complete -c stg -n __fish_stg_needs_command -s C -xa '(__fish_complete_directories)' -d 'Run as if started in this directory'
185197
complete -c stg -n __fish_stg_needs_command -l color -a 'auto always ansi never' -d 'When to colorize output'
@@ -346,7 +358,9 @@ fn get_arg_completion_params(arg: &clap::Arg) -> ShStream {
346358
"branch" | "ref-branch" => params.word("-xa '(__fish_stg_stg_branches)'"),
347359
"branch-any" => params.word("-xa '(__fish_stg_all_branches)'"),
348360
"committish" => params.word("-xa '(__fish_stg_commit)'"),
349-
"diff-opts" => params.word("-xa '(__fish_stg_diff_opts)'"),
361+
"diff-opts" => params.word("-xa '(__fish_stg_git_diff_opts)'"),
362+
"git-format-patch-opts" => params.word("-xa '(__fish_stg_git_format_patch_opts)'"),
363+
"git-send-email-opts" => params.word("-xa '(__fish_stg_git_send_email_opts)'"),
350364
"patch" | "patchranges" => params.word("-kxa '(__fish_stg_patches -A -U)'"),
351365
"patchranges-all" | "set-tree" | "stgit-revision" => {
352366
params.word("-kxa '(__fish_stg_patches --all)'")

0 commit comments

Comments
 (0)