in astro/cli/astro/cmd/cmd.go [74:108]
func NewAstroCLI(opts ...Option) (*AstroCLI, error) {
cli := &AstroCLI{
stdin: os.Stdin,
stdout: os.Stdout,
stderr: os.Stderr,
}
if err := cli.applyOptions(opts...); err != nil {
return nil, err
}
// Set up Cobra commands and structure
cli.createRootCommand()
cli.createPlanCmd()
cli.createApplyCmd()
cli.createVersionCmd()
cli.commands.root.AddCommand(
cli.commands.plan,
cli.commands.apply,
cli.commands.version,
)
// Set trace. Note, this will turn tracing on for all instances of astro
// running in the same process, as the logger is a singleton. This should
// only be of concern during testing.
cobra.OnInitialize(func() {
if cli.flags.trace {
logger.Trace.SetOutput(cli.stderr)
log.SetOutput(cli.stderr)
}
})
return cli, nil
}