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

Give script templates access to their own name and other metadata #2

Closed
anthonyrisinger opened this issue Jan 6, 2018 · 2 comments
Closed

Comments

@anthonyrisinger
Copy link

You can access options and args via function (kingpeon.go#L68) but there is no way for a script template to discover the command that triggered it, or other useful information.

This package is used by go-jira. I'm trying to make a common entry point like so:

custom-commands:
  - name: sync
    options: ...
    args: ...
    script: |
      JIRA={{jira}} exec {{jira}}-lib sync 10<<'EOF'
      {{toJson options}}
      {{toJson args}}
      EOF

The script is the same for every custom command except for the word sync (or whatever command is in play) because I don't see a way to get that info, eg. {{.name}}.

Could we assign . to the config so things like .name or .help work? Or something else?

Adding toJson and fromJson would be great too. The heredoc nonsense above is because go-jira does not compact the JSON. Lastly, a shellquote function would be massively appreciated!

@coryb
Copy link
Owner

coryb commented Jan 7, 2018

With the above change the {{.}} object will correspond to the corresponding DynamicCommand structure:
https://github.com/coryb/kingpeon/blob/master/dynamicCommands.go#L30

@anthonyrisinger
Copy link
Author

Awesome thank you!

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

No branches or pull requests

2 participants