Skip to content

Commit

Permalink
Add help text for zsh/bash completion
Browse files Browse the repository at this point in the history
  • Loading branch information
dontlaugh committed Mar 27, 2022
1 parent 93e7217 commit 9ed8b0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -98,7 +98,7 @@ Requirements:
# Installation

1. Copy the executable (from the [releases page][releases]) to somewhere in your path, named `dstask` and mark it executable. `/usr/local/bin/` is suggested.
1. Enable bash completions by copying `.bash-completion.sh` into your home directory and sourcing it from your `.bashrc`. There's also a zsh completion script.
1. Enable bash completions by copying `source <(dstask bash-completion)` into your `.bashrc`. There's also a `zsh-completion` subcommand.
1. Set up an alias in your `.bashrc`: `alias task=dstask` or `alias t=dstask` to make task management slightly faster.
1. Create or clone a ~/.dstask git repository for the data, if you haven't already: `mkdir ~/.dstask && git -C ~/.dstask init`.

Expand Down Expand Up @@ -162,6 +162,8 @@ show-open : Show all non-resolved tasks (without truncation)
show-resolved : Show resolved tasks
show-templates : Show task templates
show-unorganised : Show untagged tasks with no projects (global context)
bash-completion : Print bash completion script to stdout
zsh-completion : Print zsh completion script to stdout
help : Get help on any command or show this message
version : Show dstask version information
```
Expand Down
2 changes: 2 additions & 0 deletions completions/embed.go
Expand Up @@ -3,8 +3,10 @@ package completions
//nolint
import _ "embed"

// Zsh completion script
//go:embed zsh.sh
var Zsh string

// Bash completion script
//go:embed bash.sh
var Bash string
13 changes: 12 additions & 1 deletion help.go
Expand Up @@ -209,6 +209,15 @@ this command.
helpStr = `Usage: dstask show-projects
Show a breakdown of projects with progress information
`

case CMD_PRINT_BASH_COMPLETION, CMD_PRINT_ZSH_COMPLETION:
helpStr = `Usage: dstask [bash|zsh]-completion
Print a shell completion script to stdout. The script can be sourced from
a user's .bashrc or .zshrc like so:
source <(dstask bash-completion)
`
default:
helpStr = `Usage: dstask [id...] <cmd> [task summary/filter]
Expand Down Expand Up @@ -253,12 +262,14 @@ show-open : Show all non-resolved tasks (without truncation)
show-resolved : Show resolved tasks
show-templates : Show task templates
show-unorganised : Show untagged tasks with no projects (global context)
bash-completion : Print bash completion script to stdout
zsh-completion : Print zsh completion script to stdout
help : Get help on any command or show this message
version : Show dstask version information
Colour Key:
`

showKey = true
}
fmt.Fprint(os.Stderr, helpStr)
Expand Down

0 comments on commit 9ed8b0b

Please sign in to comment.