Skip to content

Commit 290e0e1

Browse files
committed
Rename --dest-dir to --sketch-path
1 parent 71b0902 commit 290e0e1

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

internal/cli/profile/profile_lib_add.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
func initLibAddCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
35-
var destDir string
35+
var sketchDir string
3636
var noDeps bool
3737
var noOverwrite bool
3838
var profileArg arguments.Profile
@@ -44,21 +44,21 @@ func initLibAddCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
4444
" " + os.Args[0] + " profile lib add [email protected] --profile my_profile\n",
4545
Args: cobra.MinimumNArgs(1),
4646
Run: func(cmd *cobra.Command, args []string) {
47-
runLibAddCommand(cmd.Context(), args, srv, profileArg.Get(), destDir, noDeps, noOverwrite)
47+
runLibAddCommand(cmd.Context(), args, srv, profileArg.Get(), sketchDir, noDeps, noOverwrite)
4848
},
4949
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
5050
return arguments.GetInstallableLibs(cmd.Context(), srv), cobra.ShellCompDirectiveDefault
5151
},
5252
}
5353
profileArg.AddToCommand(addCommand, srv)
54-
addCommand.Flags().StringVar(&destDir, "dest-dir", "", i18n.Tr("Location of the sketch project file."))
54+
addCommand.Flags().StringVar(&sketchDir, "sketch-path", "", i18n.Tr("Location of the sketch."))
5555
addCommand.Flags().BoolVar(&noDeps, "no-deps", false, i18n.Tr("Do not add dependencies."))
5656
addCommand.Flags().BoolVar(&noOverwrite, "no-overwrite", false, i18n.Tr("Do not overwrite already added libraries."))
5757
return addCommand
5858
}
5959

60-
func runLibAddCommand(ctx context.Context, args []string, srv rpc.ArduinoCoreServiceServer, profile, destDir string, noAddDeps, noOverwrite bool) {
61-
sketchPath := arguments.InitSketchPath(destDir)
60+
func runLibAddCommand(ctx context.Context, args []string, srv rpc.ArduinoCoreServiceServer, profile, sketchDir string, noAddDeps, noOverwrite bool) {
61+
sketchPath := arguments.InitSketchPath(sketchDir)
6262

6363
instance := instance.CreateAndInit(ctx, srv)
6464
libRefs, err := lib.ParseLibraryReferenceArgsAndAdjustCase(ctx, srv, instance, args)

internal/cli/profile/profile_lib_remove.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
func initLibRemoveCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
35-
var destDir string
35+
var sketchDir string
3636
var profileArg arguments.Profile
3737
var noDeps bool
3838
removeCommand := &cobra.Command{
@@ -43,23 +43,23 @@ func initLibRemoveCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
4343
" " + os.Args[0] + " profile lib remove [email protected] --profile my_profile\n",
4444
Args: cobra.MinimumNArgs(1),
4545
Run: func(cmd *cobra.Command, args []string) {
46-
runLibRemoveCommand(cmd.Context(), srv, args, profileArg.Get(), destDir, noDeps)
46+
runLibRemoveCommand(cmd.Context(), srv, args, profileArg.Get(), sketchDir, noDeps)
4747
},
4848
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
4949
ctx := cmd.Context()
50-
sketchPath := arguments.InitSketchPath(destDir)
50+
sketchPath := arguments.InitSketchPath(sketchDir)
5151
completions := arguments.GetProfileLibraries(ctx, srv, sketchPath, profileArg.Get())
5252
return completions, cobra.ShellCompDirectiveNoFileComp
5353
},
5454
}
5555
profileArg.AddToCommand(removeCommand, srv)
56-
removeCommand.Flags().StringVar(&destDir, "dest-dir", "", i18n.Tr("Location of the sketch project file."))
56+
removeCommand.Flags().StringVar(&sketchDir, "sketch-path", "", i18n.Tr("Location of the sketch."))
5757
removeCommand.Flags().BoolVar(&noDeps, "no-deps", false, i18n.Tr("Do not remove unused dependencies."))
5858
return removeCommand
5959
}
6060

61-
func runLibRemoveCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args []string, profile, destDir string, noDeps bool) {
62-
sketchPath := arguments.InitSketchPath(destDir)
61+
func runLibRemoveCommand(ctx context.Context, srv rpc.ArduinoCoreServiceServer, args []string, profile, sketchDir string, noDeps bool) {
62+
sketchPath := arguments.InitSketchPath(sketchDir)
6363

6464
instance := instance.CreateAndInit(ctx, srv)
6565
libRefs, err := lib.ParseLibraryReferenceArgsAndAdjustCase(ctx, srv, instance, args)

internal/cli/profile/profile_set-default.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
func initProfileSetDefaultCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Command {
30-
var destDir string
30+
var sketchDir string
3131
setDefaultCommand := &cobra.Command{
3232
Use: "set-default",
3333
Short: i18n.Tr("Set the default build profile."),
@@ -36,16 +36,16 @@ func initProfileSetDefaultCommand(srv rpc.ArduinoCoreServiceServer) *cobra.Comma
3636
" " + os.Args[0] + " profile set-default my_profile\n",
3737
Args: cobra.ExactArgs(1),
3838
Run: func(cmd *cobra.Command, args []string) {
39-
runSetDefaultCommand(cmd.Context(), args, srv, destDir)
39+
runSetDefaultCommand(cmd.Context(), args, srv, sketchDir)
4040
},
4141
}
42-
setDefaultCommand.Flags().StringVar(&destDir, "dest-dir", "", i18n.Tr("Location of the sketch project file."))
42+
setDefaultCommand.Flags().StringVar(&sketchDir, "sketch-path", "", i18n.Tr("Location of the sketch."))
4343
return setDefaultCommand
4444
}
4545

46-
func runSetDefaultCommand(ctx context.Context, args []string, srv rpc.ArduinoCoreServiceServer, destDir string) {
46+
func runSetDefaultCommand(ctx context.Context, args []string, srv rpc.ArduinoCoreServiceServer, sketchDir string) {
4747
profileName := args[0]
48-
sketchPath := arguments.InitSketchPath(destDir)
48+
sketchPath := arguments.InitSketchPath(sketchDir)
4949

5050
_, err := srv.ProfileSetDefault(ctx, &rpc.ProfileSetDefaultRequest{SketchPath: sketchPath.String(), ProfileName: profileName})
5151
if err != nil {

internal/integrationtest/profiles/profiles_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func TestProfileLib(t *testing.T) {
262262
_, _, err = cli.Run("profile", "create", sk.String(), "-m", "uno", "-b", "arduino:avr:uno", "--set-default")
263263
require.NoError(t, err)
264264

265-
out, _, err := cli.Run("profile", "lib", "add", "[email protected]", "--dest-dir", sk.String(), "--json")
265+
out, _, err := cli.Run("profile", "lib", "add", "[email protected]", "--sketch-path", sk.String(), "--json")
266266
require.NoError(t, err)
267267
requirejson.Parse(t, out).Query(".added_libraries").MustContain(`
268268
[
@@ -278,7 +278,7 @@ func TestProfileLib(t *testing.T) {
278278
require.Contains(t, string(fileContent), " - dependency: Arduino_LSM6DSOX (")
279279

280280
t.Run("ChangeLibVersionToDefaultProfile", func(t *testing.T) {
281-
out, _, err := cli.Run("profile", "lib", "add", "[email protected]", "--dest-dir", sk.String(), "--json")
281+
out, _, err := cli.Run("profile", "lib", "add", "[email protected]", "--sketch-path", sk.String(), "--json")
282282
require.NoError(t, err)
283283
outjson := requirejson.Parse(t, out)
284284
outjson.Query(".added_libraries").MustContain(`
@@ -300,7 +300,7 @@ func TestProfileLib(t *testing.T) {
300300
})
301301

302302
t.Run("RemoveLibFromDefaultProfile", func(t *testing.T) {
303-
_, _, err = cli.Run("profile", "lib", "remove", "Arduino_Modulino", "--dest-dir", sk.String())
303+
_, _, err = cli.Run("profile", "lib", "remove", "Arduino_Modulino", "--sketch-path", sk.String())
304304
require.NoError(t, err)
305305
fileContent, err := sk.Join("sketch.yaml").ReadFile()
306306
require.NoError(t, err)
@@ -310,13 +310,13 @@ func TestProfileLib(t *testing.T) {
310310
})
311311

312312
t.Run("AddInexistentLibToDefaultProfile", func(t *testing.T) {
313-
_, stderr, err := cli.Run("profile", "lib", "add", "foobar123", "--dest-dir", sk.String())
313+
_, stderr, err := cli.Run("profile", "lib", "add", "foobar123", "--sketch-path", sk.String())
314314
require.Error(t, err)
315315
require.Equal(t, "Error adding foobar123: Library 'foobar123@latest' not found\n", string(stderr))
316316
})
317317

318318
t.Run("RemoveLibNotInProfile", func(t *testing.T) {
319-
_, stderr, err := cli.Run("profile", "lib", "remove", "Arduino_JSON", "--dest-dir", sk.String())
319+
_, stderr, err := cli.Run("profile", "lib", "remove", "Arduino_JSON", "--sketch-path", sk.String())
320320
require.Error(t, err)
321321
require.Equal(t, "Error removing library Arduino_JSON from the profile: could not remove library: Library 'Arduino_JSON' not found\n", string(stderr))
322322
})
@@ -342,14 +342,14 @@ func TestProfileLibAddRemoveFromSpecificProfile(t *testing.T) {
342342
require.NoError(t, err)
343343

344344
// Add library to a specific profile
345-
_, _, err = cli.Run("profile", "lib", "add", "[email protected]", "-m", "my_profile", "--dest-dir", sk.String(), "--no-deps")
345+
_, _, err = cli.Run("profile", "lib", "add", "[email protected]", "-m", "my_profile", "--sketch-path", sk.String(), "--no-deps")
346346
require.NoError(t, err)
347347
fileContent, err := sk.Join("sketch.yaml").ReadFile()
348348
require.NoError(t, err)
349349
require.Contains(t, string(fileContent), " my_profile:\n fqbn: arduino:avr:uno\n platforms:\n - platform: arduino:avr (1.8.6)\n libraries:\n - Arduino_Modulino (0.7.0)\n")
350350

351351
// Remove library from a specific profile
352-
_, _, err = cli.Run("profile", "lib", "remove", "Arduino_Modulino", "-m", "my_profile", "--dest-dir", sk.String())
352+
_, _, err = cli.Run("profile", "lib", "remove", "Arduino_Modulino", "-m", "my_profile", "--sketch-path", sk.String())
353353
require.NoError(t, err)
354354
fileContent, err = sk.Join("sketch.yaml").ReadFile()
355355
require.NoError(t, err)
@@ -379,15 +379,15 @@ func TestProfileSetDefault(t *testing.T) {
379379
require.NotContains(t, fileContent, "default_profile: my_profile")
380380

381381
// Change default profile
382-
_, _, err = cli.Run("profile", "set-default", "my_profile", "--dest-dir", sk.String())
382+
_, _, err = cli.Run("profile", "set-default", "my_profile", "--sketch-path", sk.String())
383383
require.NoError(t, err)
384384
fileContent, err = sk.Join("sketch.yaml").ReadFileAsLines()
385385
require.NoError(t, err)
386386
require.NotContains(t, fileContent, "default_profile: uno")
387387
require.Contains(t, fileContent, "default_profile: my_profile")
388388

389389
// Changing to an inexistent profile returns an error
390-
_, stderr, err := cli.Run("profile", "set-default", "inexistent_profile", "--dest-dir", sk.String())
390+
_, stderr, err := cli.Run("profile", "set-default", "inexistent_profile", "--sketch-path", sk.String())
391391
require.Error(t, err)
392392
require.Equal(t, "Cannot set inexistent_profile as default profile: Profile 'inexistent_profile' not found\n", string(stderr))
393393
}

0 commit comments

Comments
 (0)