naggie / dstask

Git powered terminal-based todo/note manager -- markdown note page per task. Single binary!
https://calbryant.uk/blog/dstask-a-taskwarrior-alternative/
MIT License
793 stars 47 forks source link

Embed completion scripts in binary #165

Closed dontlaugh closed 2 years ago

dontlaugh commented 2 years ago

Our completion scripts can be embedded as global strings.

New zsh-completion and bash-completion subcommands print these embedded strings to stdout. Users can source them from their startup scripts:

source <(dstask zsh-completion)

Add symlinks at original completion script locations to (hopefully) ease transition for packagers. Remove these eventually.

Also, update CI test env to golang:1.16

Closes #162

dontlaugh commented 2 years ago

Seems to work. Need to check on the lint failures.

coleman@trajan /home/coleman/Code/dstask (embedded)
0 % source <(dstask zsh-completion)
dontlaugh commented 2 years ago
0 % make lint
"qa/lint.sh"
const.go:62:2: don't use ALL_CAPS in Go names; use CamelCase (golint)
    CMD_PRINT_ZSH_COMPLETION  = "zsh-completion"
    ^
const.go:63:2: don't use ALL_CAPS in Go names; use CamelCase (golint)
    CMD_PRINT_BASH_COMPLETION = "bash-completion"
    ^
completions/embed.go:3:8: a blank import should be only in a main or test package, or have a comment justifying it (golint)
import _ "embed"

We may need to adjust how these lints work? I've added some //nolint comments to keep the linter from complaining, but I don't know why, for instance, it's not complaining about other all caps constants in this file. :thinking:

dontlaugh commented 2 years ago

This is ready for review. I've opted to add //nolint where the complaints from golint seemed wrong to me. FWIW, we need a new linter anyways #167

dontlaugh commented 2 years ago

@naggie bump

naggie commented 2 years ago

Thanks @dontlaugh -- a useful change. I like the new mechanism to loading strings into the exe provided by go!

Sorry it took so long to merge.