Skip to content

Commit fc72260

Browse files
committed
Moved 'update' flags in command creation
1 parent f7828d3 commit fc72260

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Diff for: cli/update/update.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,28 @@ var tr = i18n.Tr
3131

3232
// NewCommand creates a new `update` command
3333
func NewCommand() *cobra.Command {
34+
var showOutdated bool
3435
updateCommand := &cobra.Command{
3536
Use: "update",
3637
Short: tr("Updates the index of cores and libraries"),
3738
Long: tr("Updates the index of cores and libraries to the latest versions."),
3839
Example: " " + os.Args[0] + " update",
3940
Args: cobra.NoArgs,
40-
Run: runUpdateCommand,
41+
Run: func(cmd *cobra.Command, args []string) {
42+
runUpdateCommand(showOutdated)
43+
},
4144
}
42-
updateCommand.Flags().BoolVar(&updateFlags.showOutdated, "show-outdated", false, tr("Show outdated cores and libraries after index update"))
45+
updateCommand.Flags().BoolVar(&showOutdated, "show-outdated", false, tr("Show outdated cores and libraries after index update"))
4346
return updateCommand
4447
}
4548

46-
var updateFlags struct {
47-
showOutdated bool
48-
}
49-
50-
func runUpdateCommand(cmd *cobra.Command, args []string) {
49+
func runUpdateCommand(showOutdated bool) {
5150
inst := instance.CreateInstanceAndRunFirstUpdate()
5251
logrus.Info("Executing `arduino-cli update`")
5352
lib.UpdateIndex(inst)
5453
core.UpdateIndex(inst)
5554
instance.Init(inst)
56-
if updateFlags.showOutdated {
55+
if showOutdated {
5756
outdated.Outdated(inst)
5857
}
5958
}

0 commit comments

Comments
 (0)