Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Add the default cli option that will output the default configur… #175

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading