Skip to content

Commit 1ec15e7

Browse files
authored
Merge pull request #184 from nucleogenesis/fish-completions
Add fish completions, update documentation accordingly
2 parents 3c06303 + 504640f commit 1ec15e7

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

cmd/dstask/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ func main() {
170170

171171
case dstask.CMD_PRINT_ZSH_COMPLETION:
172172
fmt.Printf(completions.Zsh)
173+
174+
case dstask.CMD_PRINT_FISH_COMPLETION:
175+
fmt.Printf(completions.Fish)
173176
default:
174177
panic("this should never happen?")
175178
}

completions/completions.fish

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env fish
2+
3+
complete -f -c dstask -a (echo (dstask _completions) | string collect)
4+
#complete -f -c task -a (echo (task _completions) | string collect)
5+
#complete -f -c t -a (echo (t _completions) | string collect)
6+

completions/embed.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ var Zsh string
1010
// Bash completion script
1111
//go:embed bash.sh
1212
var Bash string
13+
14+
// Fish completion script
15+
//go:embed completions.fish
16+
var Fish string

const.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const (
6363
CMD_PRINT_ZSH_COMPLETION = "zsh-completion"
6464
//nolint
6565
CMD_PRINT_BASH_COMPLETION = "bash-completion"
66+
//nolint
67+
CMD_PRINT_FISH_COMPLETION = "fish-completion"
6668

6769
// filter: P1 P2 etc
6870
PRIORITY_CRITICAL = "P0"
@@ -173,6 +175,7 @@ var ALL_CMDS = []string{
173175
CMD_SHOW_UNORGANISED,
174176
CMD_COMPLETIONS,
175177
CMD_PRINT_BASH_COMPLETION,
178+
CMD_PRINT_FISH_COMPLETION,
176179
CMD_PRINT_ZSH_COMPLETION,
177180
CMD_HELP,
178181
CMD_VERSION,

help.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,15 @@ this command.
211211
Show a breakdown of projects with progress information
212212
`
213213

214-
case CMD_PRINT_BASH_COMPLETION, CMD_PRINT_ZSH_COMPLETION:
215-
helpStr = `Usage: dstask [bash|zsh]-completion
214+
case CMD_PRINT_BASH_COMPLETION, CMD_PRINT_ZSH_COMPLETION, CMD_PRINT_FISH_COMPLETION:
215+
helpStr = `Usage: dstask [bash|zsh|fish]-completion
216216
217217
Print a shell completion script to stdout. The script can be sourced from
218-
a user's .bashrc or .zshrc like so:
218+
a user's .bashrc, .zshrc, or fish.config like so:
219219
220220
source <(dstask bash-completion)
221+
source <(dstask zsh-completion)
222+
dtask fish-completion | source
221223
`
222224
default:
223225
helpStr = `Usage: dstask [id...] <cmd> [task summary/filter]
@@ -263,6 +265,7 @@ show-resolved : Show resolved tasks
263265
show-templates : Show task templates
264266
show-unorganised : Show untagged tasks with no projects (global context)
265267
bash-completion : Print bash completion script to stdout
268+
fish-completion : Print fish completion script to stdout
266269
zsh-completion : Print zsh completion script to stdout
267270
help : Get help on any command or show this message
268271
version : Show dstask version information

0 commit comments

Comments
 (0)