Skip to content

Commit

Permalink
feat:Add the default cli option that will output the default configur…
Browse files Browse the repository at this point in the history
…ation to a file.
  • Loading branch information
schmidtw committed Jun 28, 2024
1 parent 301f635 commit 7aa0d15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions cmd/xmidt-agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ func provideConfig(cli *CLI) (*goschtalt.Config, error) {
return nil, err
}

if cli.Default != "" {
err := os.WriteFile("./"+cli.Default, defaultConfigFile, 0644)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
os.Exit(0)
}

if cli.Show {
// handleCLIShow handles the -s/--show option where the configuration is
// shown, then the program is exited.
Expand Down
9 changes: 5 additions & 4 deletions cmd/xmidt-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ var (

// CLI is the structure that is used to capture the command line arguments.
type CLI struct {
Dev bool `optional:"" short:"d" help:"Run in development mode."`
Show bool `optional:"" short:"s" help:"Show the configuration and exit."`
Graph string `optional:"" short:"g" help:"Output the dependency graph to the specified file."`
Files []string `optional:"" short:"f" help:"Specific configuration files or directories."`
Dev bool `optional:"" short:"d" help:"Run in development mode."`
Show bool `optional:"" short:"s" help:"Show the configuration and exit."`
Default string `optional:"" help:"Output the default configuration file as the specified file."`
Graph string `optional:"" short:"g" help:"Output the dependency graph to the specified file."`
Files []string `optional:"" short:"f" help:"Specific configuration files or directories."`
}

type LifeCycleIn struct {
Expand Down

0 comments on commit 7aa0d15

Please sign in to comment.