@@ -58,6 +58,7 @@ import (
58
58
59
59
var (
60
60
verbose bool
61
+ jsonOutput bool
61
62
outputFormat string
62
63
configFile string
63
64
)
@@ -75,6 +76,10 @@ func NewCommand() *cobra.Command {
75
76
Long : tr ("Arduino Command Line Interface (arduino-cli)." ),
76
77
Example : fmt .Sprintf (" %s <%s> [%s...]" , os .Args [0 ], tr ("command" ), tr ("flags" )),
77
78
PersistentPreRun : func (cmd * cobra.Command , args []string ) {
79
+ if jsonOutput {
80
+ outputFormat = "json"
81
+ }
82
+
78
83
preRun (cmd , args )
79
84
80
85
if cmd .Name () != "version" {
@@ -155,6 +160,8 @@ func createCliCommandTree(cmd *cobra.Command) {
155
160
cmd .RegisterFlagCompletionFunc ("format" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
156
161
return validOutputFormats , cobra .ShellCompDirectiveDefault
157
162
})
163
+ cmd .Flag ("format" ).Hidden = true
164
+ cmd .PersistentFlags ().BoolVar (& jsonOutput , "json" , false , tr ("Print the output in JSON format." ))
158
165
cmd .PersistentFlags ().StringVar (& configFile , "config-file" , "" , tr ("The custom config file (if not specified the default will be used)." ))
159
166
cmd .PersistentFlags ().StringSlice ("additional-urls" , []string {}, tr ("Comma-separated list of additional URLs for the Boards Manager." ))
160
167
cmd .PersistentFlags ().Bool ("no-color" , false , "Disable colored output." )
0 commit comments