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

promptStringOnce only stores variables under [data] #2938

Closed
2 tasks
dboeckenhoff opened this issue Apr 20, 2023 · 3 comments · Fixed by #2940
Closed
2 tasks

promptStringOnce only stores variables under [data] #2938

dboeckenhoff opened this issue Apr 20, 2023 · 3 comments · Fixed by #2940
Labels
enhancement New feature or request support Support request

Comments

@dboeckenhoff
Copy link

What exactly are you trying to do?

My .chezmoi.toml.tmpl does

{{- $database := promptStringOnce . "database" "Please add the path to your keepass2 database to be used via keepassxc cli" -}}

[keepassxc]
    database = {{ $database | quote }}

However, with chezmoi init I am always prompted the database entry request.
This is rather invonvenient. If this is possible, I'd say the proper way should be documented.

What have you tried so far?

The same syntax storing under [data] works. However, keepassxc requires the database entry to be under [keepassxc] (as I understand it).

Where else have you checked for solutions?

Finally

Thanks for this awesome project!

@dboeckenhoff dboeckenhoff added the support Support request label Apr 20, 2023
@halostatue
Copy link
Collaborator

As a workaround, you could store things twice.

{{- $database := promptStringOnce . "keepassxc-database" "Please add the path to your keepass2 database to be used via keepassxc cli" -}}

[keepassxc]
    database = {{ $database | quote }}

[data]
# This is a workaround
keepassxc-database = {{ $database | quote }}

It seems like it could be useful, at least for chezmoi init, to have .chezmoi.config.* keys available so that you could do promptStringOnce . "chezmoi.config.keepassxc.database" "DATABASE, MORTAL". I don’t know that it would be useful for normal usage.

@twpayne
Copy link
Owner

twpayne commented Apr 21, 2023

Thanks for the suggestion. Adding a .chezmoi.config template variable makes sense. Done in #2940.

@halostatue
Copy link
Collaborator

@dboeckenhoff I believe that once this is released, your template would be updated to

{{- $database := promptStringOnce . "chezmoi.config.keepassxc.database" "Please add the path to your keepass2 database to be used via keepassxc cli" -}}

[keepassxc]
    database = {{ $database | quote }}

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request support Support request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants