Skip to content

Commit a66fb99

Browse files
cli: config init
1 parent fe08033 commit a66fb99

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

internal/cli/config/init.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,21 @@ func runInitCommand(cmd *cobra.Command, args []string) {
108108
if err := newSettings.WriteConfigAs(configFileAbsPath.String()); err != nil {
109109
feedback.Fatal(tr("Cannot create config file: %v", err), feedback.ErrGeneric)
110110
}
111+
feedback.PrintResult(initResult{ConfigFileAbsPath: configFileAbsPath})
112+
}
113+
114+
// output from this command requires special formatting, let's create a dedicated
115+
// feedback.Result implementation
116+
type initResult struct {
117+
ConfigFileAbsPath *paths.Path `json:"config_path"`
118+
}
119+
120+
func (dr initResult) Data() interface{} {
121+
return dr
122+
}
111123

112-
msg := tr("Config file written to: %s", configFileAbsPath.String())
124+
func (dr initResult) String() string {
125+
msg := tr("Config file written to: %s", dr.ConfigFileAbsPath.String())
113126
logrus.Info(msg)
114-
feedback.Print(msg)
127+
return msg
115128
}

0 commit comments

Comments
 (0)