fix(configcmd): config create --output - prints the template to stdout
It wrote a file named "-" in the working directory instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5d141c7cef
commit
975340b5f7
2 files changed
+28
-3
No files matched your search
@@ -2,7 +2,7 @@
|
||||
// Yetano program standard (docs/program-conventions.md and ADR-0012 in
|
||||
// the yetano meta-repository):
|
||||
//
|
||||
// <program> config create [--minimal|--full] [--force] [--output <file>]
|
||||
// <program> config create [--minimal|--full] [--force] [--output <file>|-]
|
||||
// <program> config validate
|
||||
// <program> config upgrade [--write]
|
||||
// <program> config path
|
||||
@@ -201,7 +201,7 @@ func usage(s Spec, w io.Writer) {
|
||||
}
|
||||
fmt.Fprintf(w, `usage: %[1]s config <subcommand> [--config <file>]
|
||||
|
||||
create [--minimal|--full] [--force] [--output <file>]
|
||||
create [--minimal|--full] [--force] [--output <file>|-]
|
||||
write a commented starter configuration (minimal by default)
|
||||
validate check the configuration file the program would use
|
||||
upgrade [--write]
|
||||
@@ -342,7 +342,7 @@ func (s Spec) create(explicit string, args []string, stdout, stderr io.Writer) i
|
||||
minimal := fs.Bool("minimal", false, "write the minimal starter configuration (default)")
|
||||
full := fs.Bool("full", false, "write the fully commented reference configuration")
|
||||
force := fs.Bool("force", false, "overwrite the file if it already exists")
|
||||
output := fs.String("output", "", "file to write (default: --config, else the file the program would use, else "+s.filename()+" in the user config directory -- the system one as root)")
|
||||
output := fs.String("output", "", "file to write, - for stdout (default: --config, else the file the program would use, else "+s.filename()+" in the user config directory -- the system one as root)")
|
||||
if code := parse(fs, args); code >= 0 {
|
||||
return code
|
||||
}
|
||||
@@ -356,6 +356,10 @@ func (s Spec) create(explicit string, args []string, stdout, stderr io.Writer) i
|
||||
}
|
||||
|
||||
path := *output
|
||||
if path == "-" { // the template on stdout, nothing written
|
||||
io.WriteString(stdout, content)
|
||||
return ExitOK
|
||||
}
|
||||
if path == "" {
|
||||
var err error
|
||||
if path, err = s.defaultCreatePath(explicit); err != nil {
|
||||
|
||||
Reference in new issue
Block a user