File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -239,6 +239,13 @@ func GetAllSeq[T any](c *Command, id string) iter.Seq[T] {
239239 }
240240}
241241
242+ // Fatal logs the given value to Stderr prefixed by "error: "
243+ // and then exits the program with the given code.
244+ func Fatal (code int , v any ) {
245+ fmt .Fprintf (os .Stderr , "error: %v\n " , v )
246+ os .Exit (code )
247+ }
248+
242249// ParseOrExit will parse input based on this CommandInfo. If help was requested, it
243250// will print the help message and exit the program successfully (status code 0). If
244251// there is any other error, it will print the error and exit the program with failure
@@ -254,8 +261,7 @@ func (in CommandInfo) ParseTheseOrExit(args ...string) *Command {
254261 fmt .Print (e .HelpMsg )
255262 os .Exit (0 )
256263 } else {
257- fmt .Fprintf (os .Stderr , "error: %v\n " , err )
258- os .Exit (1 )
264+ Fatal (1 , err )
259265 }
260266 }
261267 return c
You can’t perform that action at this time.
0 commit comments