Skip to content

Commit dc4ef88

Browse files
committed
Add alias "install" to sync command
1 parent 57f4cb8 commit dc4ef88

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎internal/cli/root_test.go‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package cli
22

3-
import "testing"
3+
import (
4+
"slices"
5+
"testing"
6+
7+
"github.com/spf13/cobra"
8+
)
49

510
func TestRoot(t *testing.T) {
611
r := Root()
@@ -11,3 +16,20 @@ func TestRoot(t *testing.T) {
1116
t.Error("Version should be set")
1217
}
1318
}
19+
20+
func TestSyncInstallAlias(t *testing.T) {
21+
r := Root()
22+
var sync *cobra.Command
23+
for _, c := range r.Commands() {
24+
if c.Use == "sync" {
25+
sync = c
26+
break
27+
}
28+
}
29+
if sync == nil {
30+
t.Fatal("sync command not registered")
31+
}
32+
if !slices.Contains(sync.Aliases, "install") {
33+
t.Errorf("sync.Aliases = %v; want to contain \"install\"", sync.Aliases)
34+
}
35+
}

‎internal/cli/sync.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ func newSyncCmd() *cobra.Command {
2525
var jsonOut bool
2626
var sigMode string
2727
cmd := &cobra.Command{
28-
Use: "sync",
29-
Short: "Resolve manifest, fetch assets, write lockfile",
28+
Use: "sync",
29+
Aliases: []string{"install"},
30+
Short: "Resolve manifest, fetch assets, write lockfile",
3031
Long: `Resolve pin.yaml against the registry, fetch the requested files,
3132
verify their integrity, and write pin.lock plus the vendored files under
3233
the manifest's out: directory.

0 commit comments

Comments
 (0)