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

Bare task names list for completion #46

Closed
rafi opened this issue Sep 16, 2020 · 4 comments · Fixed by #47
Closed

Bare task names list for completion #46

rafi opened this issue Sep 16, 2020 · 4 comments · Fixed by #47
Assignees

Comments

@rafi
Copy link

rafi commented Sep 16, 2020

It would be nice to have a way to list task names without colors and formatting so it could be consumed by a bash/zsh/fish completion script for the task name. Something like robo -q ?

Adding this to robo.yml:

templates:
  list: |-
    {{range .Tasks}}{{.Name}}{{ print "\n" }}{{end}}

And sourcing this bash completion:

#/usr/bin/env bash
_robo_completion() {
  if [ "${#COMP_WORDS[@]}" != "2" ]; then
    return
  fi
  COMPREPLY=($(compgen -W "$(robo)" -- "${COMP_WORDS[1]}"))
}

complete -F _robo_completion robo

Works nicely. But it's annoying adding the list template in each robo.yml file.

@yields
Copy link
Collaborator

yields commented Sep 18, 2020

Nice use case, perhaps we should use github.com/alecthomas/colour, from it's TTY() docs:

$ go doc colour.TTY
func TTY(w io.Writer) Printer
    TTY creates a Printer that colourises output if w is a terminal, or strips
    formatting if it is not.

Other solutions might be to add completions automatically for shells like zsh and bash, or a --json flag that will output JSON?

I'll see if I have 30m this weekend to whip up a PR.

@yields yields self-assigned this Sep 18, 2020
@yields
Copy link
Collaborator

yields commented Sep 18, 2020

Actually haven't thought about it a bit, it seems like -q is the simplest way to go about it, similar to how docker outputs verbose info but only lists the IDs with -q.

@rafi
Copy link
Author

rafi commented Sep 19, 2020

Exactly my thoughts @yields, same as docker lists only the IDs with -q.

yields added a commit that referenced this issue Sep 19, 2020
The option renders the task names only, allows users to implement scripting
easily with robo.

Closes #46.
@yields
Copy link
Collaborator

yields commented Sep 19, 2020

Released v0.7.0:

  λ ~ robo --version
0.7.0
  λ ~ robo -q
dev
stage
prod
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants