Skip to content

Commit 32d69d9

Browse files
authored
refactor(devtools/cmd/migrate-sidekick): change repo from flag to arg (#3186)
The repo path is now passed as the first positional argument instead of using the -repo flag. This simplifies the command usage to `migrate-sidekick .` when running inside google-cloud-rust, since repo is a required path.
1 parent 91684f9 commit 32d69d9

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

devtools/cmd/migrate-sidekick/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
)
3838

3939
var (
40-
errRepoNotFound = errors.New("-repo flag is required")
40+
errRepoNotFound = errors.New("repo path argument is required")
4141
errSidekickNotFound = errors.New(".sidekick.toml not found")
4242
errSrcNotFound = errors.New("src/generated directory not found")
4343
errTidyFailed = errors.New("librarian tidy failed")
@@ -81,26 +81,26 @@ func main() {
8181

8282
func run(args []string) error {
8383
flagSet := flag.NewFlagSet("migrate-sidekick", flag.ContinueOnError)
84-
repoPath := flagSet.String("repo", "", "Path to the google-cloud-rust repository (required)")
8584
outputPath := flagSet.String("output", "./librarian.yaml", "Output file path (default: ./librarian.yaml)")
86-
if err := flagSet.Parse(args[1:]); err != nil {
85+
if err := flagSet.Parse(args); err != nil {
8786
return err
8887
}
8988

90-
if *repoPath == "" {
89+
if flagSet.NArg() < 1 {
9190
return errRepoNotFound
9291
}
92+
repoPath := flagSet.Arg(0)
9393

9494
slog.Info("Reading sidekick.toml...", "path", repoPath)
9595

9696
// Read root .sidekick.toml for defaults
97-
defaults, err := readRootSidekick(*repoPath)
97+
defaults, err := readRootSidekick(repoPath)
9898
if err != nil {
9999
return fmt.Errorf("failed to read root .sidekick.toml: %w", err)
100100
}
101101

102102
// Find all .sidekick.toml files
103-
sidekickFiles, err := findSidekickFiles(*repoPath)
103+
sidekickFiles, err := findSidekickFiles(repoPath)
104104
if err != nil {
105105
return fmt.Errorf("failed to find sidekick.toml files: %w", err)
106106
}

devtools/cmd/migrate-sidekick/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func TestRunMigrateCommand(t *testing.T) {
436436
}
437437
})
438438

439-
if err := run([]string{"migrate-sidekick", "-repo", test.path}); err != nil {
439+
if err := run([]string{test.path}); err != nil {
440440
if test.wantErr == nil {
441441
t.Fatal(err)
442442
}

migrate-sidekick

18.3 MB
Binary file not shown.

0 commit comments

Comments
 (0)