Code Monkey home page Code Monkey logo

Comments (2)

twpayne avatar twpayne commented on September 21, 2024

Drive-by notes for later:

For testing the 2nd and 3rd commands, I used the following testscript change:

diff --git a/internal/cmd/testdata/scripts/editconfigtemplate.txtar b/internal/cmd/testdata/scripts/editconfigtemplate.txtar
index 7c705ae3a..c791315c2 100644
--- a/internal/cmd/testdata/scripts/editconfigtemplate.txtar
+++ b/internal/cmd/testdata/scripts/editconfigtemplate.txtar
@@ -22,6 +22,18 @@ chhome home4/user
 exec chezmoi edit-config-template
 cmp $CHEZMOISOURCEDIR/home/.chezmoi.yaml.tmpl golden/edited-chezmoi.yaml
 
+chhome home5/user
+
+# test chezmoi edit-config-template --config with a non-existent config file
+exec chezmoi --config=config.yaml --config-format=yaml edit-config-template
+cmp $CHEZMOISOURCEDIR/.config.yaml.tmpl golden/edited
+
+chhome home6/user
+
+# test chezmoi edit-config-template --config-format with a non-existent config file
+exec chezmoi --config-format=yaml edit-config-template
+cmp $CHEZMOISOURCEDIR/.config.yaml.tmpl golden/edited
+
 -- golden/edited --
 # edited
 -- golden/edited-chezmoi.yaml --

Re

The 4th command should edit the file .chezmoi.json.tmpl

where the 4th command is:

% HOME=/tmp/chezmoi EDITOR=echo chezmoi --config config.yaml --config-format json edit-config-template
/tmp/chezmoi/.local/share/chezmoi/.config.yaml.tmpl
chezmoi: warning: /bin/echo /tmp/chezmoi/.local/share/chezmoi/.config.yaml.tmpl: returned in less than 1s

There's a direct conflict here between --config and --config-format. In this case, I would suggest the rule that --config-format is only used when creating a new config file, i.e. that --config-file is ignored in this case (possibly with a warning) and this 4th command should edit .chezmoi.yaml.tmpl.

from chezmoi.

paltherr avatar paltherr commented on September 21, 2024

Your first test should not include --config-format=yaml, (only --config=config.yaml).

I agree that for the 4th command the --config option should be ignored, i.e., the --config-format option supersedes whatever format might be implied by the --config option. However, this implies that the edited file should be .chezmoi.json.tmpl (json, not yaml).

You should add a 3rd new test:

exec chezmoi --config=config.toml --config-format=yaml edit-config-template
cmp $CHEZMOISOURCEDIR/.config.yaml.tmpl golden/edited

from chezmoi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.