Closed abhinav closed 1 year ago
This makes a minor refactor to main to avoid use of a global exit code variable.
Instead, we declare a mainCmd struct that stores global program state like exitCode.
This also allows us to change the definition of stdin, stdout, and stderr, so that tests can provide varying values.
This contains no logic changes. All changes are mechanical. Roughly:
report(error)
report
flag.Parse()
os.Args
flag.CommandLine.Parse
exitCode
This makes a minor refactor to main to avoid use of a global exit code variable.
Instead, we declare a mainCmd struct that stores global program state like exitCode.
This also allows us to change the definition of stdin, stdout, and stderr, so that tests can provide varying values.
This contains no logic changes. All changes are mechanical. Roughly:
report(error)
into a method that manipulates state on mainCmd.report
into a method, and every function that calls that as well.flag.Parse()
, which operates onos.Args
, callflag.CommandLine.Parse
with a specific list of arguments.exitCode
variable.