Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
6aa742ff
Commit
6aa742ff
authored
Apr 21, 2024
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Config set adds only unique values
parent
384c30c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
internal/algorithms/slices.go
internal/algorithms/slices.go
+14
-0
internal/cli/config/set.go
internal/cli/config/set.go
+3
-2
No files found.
internal/algorithms/slices.go
View file @
6aa742ff
...
...
@@ -71,3 +71,17 @@ func NotEquals[T comparable](value T) Matcher[T] {
return
x
!=
value
}
}
// Uniq return a copy of the input array with all duplicates removed
func
Uniq
[
T
comparable
](
in
[]
T
)
[]
T
{
have
:=
map
[
T
]
bool
{}
var
out
[]
T
for
_
,
v
:=
range
in
{
if
have
[
v
]
{
continue
}
out
=
append
(
out
,
v
)
have
[
v
]
=
true
}
return
out
}
internal/cli/config/set.go
View file @
6aa742ff
...
...
@@ -20,6 +20,7 @@ import (
"encoding/json"
"os"
f
"github.com/arduino/arduino-cli/internal/algorithms"
"github.com/arduino/arduino-cli/internal/cli/feedback"
rpc
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/sirupsen/logrus"
...
...
@@ -59,8 +60,8 @@ func runSetCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args [
req
.
EncodedValue
=
args
[
1
]
req
.
ValueFormat
=
"cli"
}
else
{
// Array
jsonValues
,
err
:=
json
.
Marshal
(
args
[
1
:
]
)
//
Uniq
Array
jsonValues
,
err
:=
json
.
Marshal
(
f
.
Uniq
(
args
[
1
:
])
)
if
err
!=
nil
{
feedback
.
Fatal
(
tr
(
"Error setting value: %v"
,
err
),
feedback
.
ErrGeneric
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment