Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed completion scripts in binary #165

Merged
merged 3 commits into from Apr 18, 2022
Merged

Conversation

dontlaugh
Copy link
Contributor

@dontlaugh dontlaugh commented Jan 29, 2022

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
Copy link
Contributor Author

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

coleman@trajan /home/coleman/Code/dstask (embedded)
0 % source <(dstask zsh-completion)

@dontlaugh
Copy link
Contributor Author

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. 🤔

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
@dontlaugh
Copy link
Contributor Author

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 dontlaugh marked this pull request as ready for review March 27, 2022 02:56
@dontlaugh
Copy link
Contributor Author

@naggie bump

@naggie naggie merged commit 566325b into naggie:master Apr 18, 2022
@naggie
Copy link
Owner

naggie commented Apr 18, 2022

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.

@dontlaugh dontlaugh deleted the embedded branch April 18, 2022 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Embed shell completion scripts in binary, provide completion subcommand
2 participants