Skip to content

Remove yaml output format from --format flag. / Deprecate --format json in favor of --json #2587

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

Merged
merged 3 commits into from
May 3, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Deprecated '--format json' in favor of '--json'
  • Loading branch information
cmaglie committed Apr 29, 2024
commit c0dfacc8d23d7bbeeb33765aa37a4f618a5f2f09
7 changes: 7 additions & 0 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (

var (
verbose bool
jsonOutput bool
outputFormat string
configFile string
)
Expand All @@ -75,6 +76,10 @@ func NewCommand() *cobra.Command {
Long: tr("Arduino Command Line Interface (arduino-cli)."),
Example: fmt.Sprintf(" %s <%s> [%s...]", os.Args[0], tr("command"), tr("flags")),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if jsonOutput {
outputFormat = "json"
}

preRun(cmd, args)

if cmd.Name() != "version" {
Expand Down Expand Up @@ -155,6 +160,8 @@ func createCliCommandTree(cmd *cobra.Command) {
cmd.RegisterFlagCompletionFunc("format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return validOutputFormats, cobra.ShellCompDirectiveDefault
})
cmd.Flag("format").Hidden = true
cmd.PersistentFlags().BoolVar(&jsonOutput, "json", false, tr("Print the output in JSON format."))
cmd.PersistentFlags().StringVar(&configFile, "config-file", "", tr("The custom config file (if not specified the default will be used)."))
cmd.PersistentFlags().StringSlice("additional-urls", []string{}, tr("Comma-separated list of additional URLs for the Boards Manager."))
cmd.PersistentFlags().Bool("no-color", false, "Disable colored output.")
Expand Down