Skip to content

Commit 2063b6a

Browse files
authored
Remove yaml output format from --format flag. / Deprecate --format json in favor of --json (#2587)
* Removed 'yaml' output from '--format' flag * Deprecated '--format json' in favor of '--json' * Updated all --format json references to use --json
1 parent 96cf962 commit 2063b6a

26 files changed

+257
-1150
lines changed

.licenses/go/sigs.k8s.io/yaml.dep.yml

Lines changed: 0 additions & 317 deletions
This file was deleted.

.licenses/go/sigs.k8s.io/yaml/goyaml.v2.dep.yml

Lines changed: 0 additions & 571 deletions
This file was deleted.

docs/UPGRADING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Here you can find a list of migration guides to handle breaking changes between
44

55
## 0.36.0
66

7+
### YAML output format is no more supported
8+
9+
The `yaml` option of the `--format` flag is no more supported. Use `--format json` if machine parsable output is needed.
10+
711
### The gRPC `cc.arduino.cli.commands.v1.CompileRequest.export_binaries` changed type.
812

913
Previously the field `export_binaries` was a `google.protobuf.BoolValue`. We used this type because it expresses this

docs/getting-started.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,35 @@ IDE. Let's see some examples.
88

99
```console
1010
$ arduino-cli help core
11-
Arduino Core operations.
11+
Arduino core operations.
1212

1313
Usage:
14-
arduino-cli core [command]
14+
arduino-cli core [command]
1515

1616
Examples:
17-
./arduino-cli core update-index
17+
arduino-cli core update-index
1818

1919
Available Commands:
20-
download Downloads one or more cores and corresponding tool dependencies.
21-
install Installs one or more cores and corresponding tool dependencies.
22-
list Shows the list of installed platforms.
23-
search Search for a core in Boards Manager.
24-
uninstall Uninstalls one or more cores and corresponding tool dependencies if no more used.
25-
update-index Updates the index of cores.
26-
upgrade Upgrades one or all installed platforms to the latest version.
20+
download Downloads one or more cores and corresponding tool dependencies.
21+
install Installs one or more cores and corresponding tool dependencies.
22+
list Shows the list of installed platforms.
23+
search Search for a core in Boards Manager.
24+
uninstall Uninstalls one or more cores and corresponding tool dependencies if no longer used.
25+
update-index Updates the index of cores.
26+
upgrade Upgrades one or all installed platforms to the latest version.
2727

2828
Flags:
29-
-h, --help help for core
29+
-h, --help help for core
3030

3131
Global Flags:
32-
--additional-urls strings Additional URLs for Boards Manager.
33-
--config-file string The custom config file (if not specified the default will be used).
34-
--format string The output format, can be [text|json]. (default "text")
35-
--log-file string Path to the file where logs will be written.
36-
--log-format string The output format for the logs, can be [text|json].
37-
--log-level string Messages with this level and above will be logged.
38-
-v, --verbose Print the logs on the standard output.
32+
--additional-urls strings Comma-separated list of additional URLs for the Boards Manager.
33+
--config-file string The custom config file (if not specified the default will be used).
34+
--json Print the output in JSON format.
35+
--log Print the logs on the standard output.
36+
--log-file string Path to the file where logs will be written.
37+
--log-format string The output format for the logs, can be: text, json
38+
--log-level string Messages with this level and above will be logged. Valid levels are: trace, debug, info, warn, error, fatal, panic
39+
--no-color Disable colored output.
3940

4041
Use "arduino-cli core [command] --help" for more information about a command.
4142
```

docs/versioning.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ The following changes to the command-line syntax are NOT considered breaking:
4545
Any change in the **human-readable** text output is **NOT** considered a breaking change. In general, the human-readable
4646
text is subject to translation and small adjustments in natural language syntax and presentation.
4747

48-
We will consider breaking changes only in the **machine-readable** output of the commands using the `--format json`
49-
flag. In particular, we have a breaking change in the JSON command output if:
48+
We will consider breaking changes only in the **machine-readable** output of the commands using the `--json` flag. In
49+
particular, we have a breaking change in the JSON command output if:
5050

5151
- a key in a JSON object is renamed or removed.
5252
- a value in a JSON object or array changes meaning or changes format.

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ require (
4444
google.golang.org/grpc v1.62.1
4545
google.golang.org/protobuf v1.33.0
4646
gopkg.in/yaml.v3 v3.0.1
47-
sigs.k8s.io/yaml v1.4.0
4847
)
4948

5049
require (

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
8282
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
8383
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
8484
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
85-
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
8685
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
8786
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
8887
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
@@ -300,5 +299,3 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
300299
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
301300
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
302301
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
303-
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
304-
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=

internal/cli/cli.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import (
5858

5959
var (
6060
verbose bool
61+
jsonOutput bool
6162
outputFormat string
6263
configFile string
6364
)
@@ -75,6 +76,10 @@ func NewCommand() *cobra.Command {
7576
Long: tr("Arduino Command Line Interface (arduino-cli)."),
7677
Example: fmt.Sprintf(" %s <%s> [%s...]", os.Args[0], tr("command"), tr("flags")),
7778
PersistentPreRun: func(cmd *cobra.Command, args []string) {
79+
if jsonOutput {
80+
outputFormat = "json"
81+
}
82+
7883
preRun(cmd, args)
7984

8085
if cmd.Name() != "version" {
@@ -150,11 +155,13 @@ func createCliCommandTree(cmd *cobra.Command) {
150155
cmd.RegisterFlagCompletionFunc("log-format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
151156
return validLogFormats, cobra.ShellCompDirectiveDefault
152157
})
153-
validOutputFormats := []string{"text", "json", "jsonmini", "yaml"}
154-
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", tr("The output format for the logs, can be: %s", strings.Join(validOutputFormats, ", ")))
158+
validOutputFormats := []string{"text", "json", "jsonmini"}
159+
cmd.PersistentFlags().StringVar(&outputFormat, "format", "text", tr("The command output format, can be: %s", strings.Join(validOutputFormats, ", ")))
155160
cmd.RegisterFlagCompletionFunc("format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
156161
return validOutputFormats, cobra.ShellCompDirectiveDefault
157162
})
163+
cmd.Flag("format").Hidden = true
164+
cmd.PersistentFlags().BoolVar(&jsonOutput, "json", false, tr("Print the output in JSON format."))
158165
cmd.PersistentFlags().StringVar(&configFile, "config-file", "", tr("The custom config file (if not specified the default will be used)."))
159166
cmd.PersistentFlags().StringSlice("additional-urls", []string{}, tr("Comma-separated list of additional URLs for the Boards Manager."))
160167
cmd.PersistentFlags().Bool("no-color", false, "Disable colored output.")

internal/cli/core/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func Upgrade(inst *rpc.Instance, args []string, skipPostInstall bool, skipPreUni
142142
feedback.PrintResult(&platformUpgradeResult{})
143143
}
144144

145-
// This is needed so we can print warning messages in case users use --format json
145+
// This is needed so we can print warning messages in case users use --json
146146
type platformUpgradeResult struct{}
147147

148148
// Data implements feedback.Result.

internal/cli/feedback/feedback.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626

2727
"github.com/arduino/arduino-cli/internal/i18n"
2828
"github.com/sirupsen/logrus"
29-
"sigs.k8s.io/yaml"
3029
)
3130

3231
// OutputFormat is an output format
@@ -39,14 +38,11 @@ const (
3938
JSON
4039
// MinifiedJSON format
4140
MinifiedJSON
42-
// YAML format
43-
YAML
4441
)
4542

4643
var formats = map[string]OutputFormat{
4744
"json": JSON,
4845
"jsonmini": MinifiedJSON,
49-
"yaml": YAML,
5046
"text": Text,
5147
}
5248

@@ -204,8 +200,6 @@ func Fatal(errorMsg string, exitCode ExitCode) {
204200
d, _ = json.MarshalIndent(augment(res), "", " ")
205201
case MinifiedJSON:
206202
d, _ = json.Marshal(augment(res))
207-
case YAML:
208-
d, _ = yaml.Marshal(augment(res))
209203
default:
210204
panic("unknown output format")
211205
}
@@ -250,12 +244,6 @@ func PrintResult(res Result) {
250244
Fatal(tr("Error during JSON encoding of the output: %v", err), ErrGeneric)
251245
}
252246
data = string(d)
253-
case YAML:
254-
d, err := yaml.Marshal(augment(res.Data()))
255-
if err != nil {
256-
Fatal(tr("Error during YAML encoding of the output: %v", err), ErrGeneric)
257-
}
258-
data = string(d)
259247
case Text:
260248
data = res.String()
261249
if resErr, ok := res.(ErrorResult); ok {

0 commit comments

Comments
 (0)