Default values for custom choices #800
-
I'd like to collect GH username and author name for building out the changelog. However I'm for the most part the primary contributor to my project. To save myself having to type that out all the time I thought it could be useful to allow setting a default value for a custom property. Ideally this would act like a placeholder; with the value pre-populated with the default, but goes away if the user were to start typing. I.e. if user doesn't customize/change it, uses default, but the user doesn't have to backspace the whole thing just to use their own value. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hm, not really, the best I could come up with is by doing: # .changie.yaml
changeFormat: '{{.Body}} by {{.Custom.Author}}'
custom:
- key: Author
type: string Then wrap changie new with something like: export CHANGIE_AUTHOR="your name here"
changie new --custom Author="${CHANGIE_AUTHOR}" Not ideal, I thought for sure # .changie.yaml
envPrefix: CHANGIE_
custom:
- key: Author
type: string ^ same as before really export CHANGIE_CUSTOM_AUTHOR="your name again"
changie new # no wrapping required changie could pull CHANGIE_ env vars for the new command and map CUSTOM_ prefixed values to the custom map just like the It is also possible to just support placeholders or default values to all inputs, but when I thought about this before I figured if there was a default you could just do something like: changieFormat: '{{.body}} {{ if .Custom.Author }}{{.Custom.Author}}{{else}}miniscruff{{end}}' But then again I just wouldn't include the author if it was me so I would just skip the else part. |
Beta Was this translation helpful? Give feedback.
Yea, I think injecting the env vars before cli arguments including the custom values would work fine.