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

algocfg: Add print option to algocfg. #5824

Merged
merged 7 commits into from
Nov 13, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions cmd/algocfg/profileCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
rootCmd.AddCommand(profileCmd)
profileCmd.AddCommand(setProfileCmd)
setProfileCmd.Flags().BoolVarP(&forceUpdate, "yes", "y", false, "Force updates to be written")
profileCmd.AddCommand(printProfileCmd)
profileCmd.AddCommand(listProfileCmd)
}

Expand Down Expand Up @@ -133,6 +134,24 @@
},
}

var printProfileCmd = &cobra.Command{
Use: "print",
Short: "Print config.json to stdout.",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
cfg, err := getConfigForArg(args[0])
if err != nil {
reportErrorf("%v", err)

Check warning on line 144 in cmd/algocfg/profileCommand.go

View check run for this annotation

Codecov / codecov/patch

cmd/algocfg/profileCommand.go#L141-L144

Added lines #L141 - L144 were not covered by tests
}
stdoutName := os.Stdout.Name()
err = codecs.SaveNonDefaultValuesToFile(stdoutName, cfg, config.GetDefaultLocal(), nil, true)
jasonpaulos marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
reportErrorf("Error saving updated config file '%s' - %s", stdoutName, err)

Check warning on line 149 in cmd/algocfg/profileCommand.go

View check run for this annotation

Codecov / codecov/patch

cmd/algocfg/profileCommand.go#L146-L149

Added lines #L146 - L149 were not covered by tests
}
fmt.Fprintf(os.Stdout, "\n")

Check warning on line 151 in cmd/algocfg/profileCommand.go

View check run for this annotation

Codecov / codecov/patch

cmd/algocfg/profileCommand.go#L151

Added line #L151 was not covered by tests
},
}

var setProfileCmd = &cobra.Command{
Use: "set",
Short: "Set config.json file from a profile.",
Expand Down