Skip to content

Commit 8ffd7c3

Browse files
author
Luca Bianconi
committed
refactor: renamed mode
1 parent ef873b8 commit 8ffd7c3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

internal/cli/compile/compile.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ type showPropertiesMode enumflag.Flag
5050
const (
5151
showPropertiesModeDisabled showPropertiesMode = iota // default when missing flag
5252
showPropertiesModePattern
53-
showPropertiesModeExpanded
53+
showPropertiesModeValue
5454
)
5555

5656
var showPropertiesModeIds = map[showPropertiesMode][]string{
57-
showPropertiesModeExpanded: {"expanded"},
57+
showPropertiesModeDisabled: {"disabled"},
58+
showPropertiesModeValue: {"value"},
5859
showPropertiesModePattern: {"pattern"},
5960
}
6061

@@ -111,9 +112,9 @@ func NewCommand() *cobra.Command {
111112
profileArg.AddToCommand(compileCommand)
112113
compileCommand.Flags().BoolVar(&dumpProfile, "dump-profile", false, tr("Create and print a profile configuration from the build."))
113114
compileCommand.Flags().Var(
114-
enumflag.New(&showProperties, "show-properties", showPropertiesModeIds, enumflag.EnumCaseInsensitive),
115+
enumflag.New(&showProperties, "string", showPropertiesModeIds, enumflag.EnumCaseInsensitive),
115116
"show-properties",
116-
tr("Show all build properties used instead of compiling."),
117+
tr(`Show build properties instead of compiling. With "pattern" properties are returned as they are defined. If "value" the placeholders are replaced with compilation context values.`),
117118
)
118119
compileCommand.Flags().Lookup("show-properties").NoOptDefVal = "pattern" // default if the flag is present with no value
119120
compileCommand.Flags().BoolVar(&preprocess, "preprocess", false, tr("Print preprocessed code to stdout instead of compiling."))
@@ -373,7 +374,7 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
373374
}
374375
feedback.FatalResult(res, feedback.ErrGeneric)
375376
}
376-
if showProperties == showPropertiesModeExpanded {
377+
if showProperties == showPropertiesModeValue {
377378
expandPropertiesInResult(res)
378379
}
379380
feedback.PrintResult(res)

internal/integrationtest/compile_3/compile_show_properties_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@ func TestCompileShowProperties(t *testing.T) {
9595
require.True(t, props.ContainsKey("archive_file_path"))
9696
require.Contains(t, props.Get("archive_file_path"), "{build.path}")
9797

98-
// Test --show-properties=expanded output is clean
98+
// Test --show-properties=value output is clean
9999
// properties are expanded
100-
stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=expanded", bareMinimum.String())
100+
stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=value", bareMinimum.String())
101101
require.NoError(t, err)
102102
props, err = properties.LoadFromBytes(stdout)
103103
require.NoError(t, err, "Output must be a clean property list")
104104
require.Empty(t, stderr)
105105
require.True(t, props.ContainsKey("archive_file_path"))
106106
require.NotContains(t, props.Get("archive_file_path"), "{build.path}")
107107

108-
// Test --show-properties=expanded --format JSON output is clean
108+
// Test --show-properties=value --format JSON output is clean
109109
// properties are expanded
110-
stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=expanded", "--format", "json", bareMinimum.String())
110+
stdout, stderr, err = cli.Run("compile", "--fqbn", "arduino:avr:uno", "-v", "--show-properties=value", "--format", "json", bareMinimum.String())
111111
require.NoError(t, err)
112112
require.Empty(t, stderr)
113113
props, err = properties.LoadFromSlice(

0 commit comments

Comments
 (0)