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

feat: pass additional data/vars into the templates #261

Open
davidalpert opened this issue Nov 27, 2023 · 0 comments · May be fixed by #262
Open

feat: pass additional data/vars into the templates #261

davidalpert opened this issue Nov 27, 2023 · 0 comments · May be fixed by #262

Comments

@davidalpert
Copy link

Sometimes when generating change notes it becomes useful to include data that is not present in the source code and is only known at build time while generating the change log. An example might be a build number that is generated by a CI/CD build server.

It would be nice to be able to pass variables into the changelog templates as command-line arguments:

  1. a slice of string --arg name value flags similar to jq (e.g. --arg build_number 123)

    --arg name value
    

    This option passes a value to the jq program as a predefined variable. If you run jq with --arg foo bar, then $foo is available in the program and has the value "bar".

  2. --arg-json '{"build_number": 123}'

  3. --arg-file /path/to/args.json

    where /path/to/args.json looks like this

    {
      "build_number": 123
    }
    

in all cases the accumulated key/value pairs could be made available to the template as a map[string]interface and accessed via the index template function

{{ index .Args "build_number" }}

If this request is aligned with the direction of this project I would be happy to contribute a pull request.

davidalpert added a commit to davidalpert/git-chglog that referenced this issue Nov 28, 2023
this commit addresses git-chglog#261 by allowing the passing of
arbitrary key=value arguments into the command line
and exposing them as part of RenderData for use
in the templates

resolves: git-chglog#261
davidalpert added a commit to davidalpert/git-chglog that referenced this issue Nov 28, 2023
this commit addresses git-chglog#261 by allowing the passing of
arbitrary key=value arguments into the command line
and exposing them as part of RenderData for use
in the templates

resolves: git-chglog#261
@davidalpert davidalpert linked a pull request Nov 28, 2023 that will close this issue
2 tasks
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 a pull request may close this issue.

1 participant