Skip to content

Commit

Permalink
Merge pull request #10837 from filecoin-project/feat/ux-friendly-batc…
Browse files Browse the repository at this point in the history
…h-cmd

feat: cli: More ux-friendly batching cmds
  • Loading branch information
rjan90 authored May 8, 2023
2 parents 0476632 + 059cbed commit 5697645
Showing 1 changed file with 48 additions and 6 deletions.
54 changes: 48 additions & 6 deletions cmd/lotus-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -1922,10 +1922,31 @@ var sectorsBatchingPendingCommit = &cli.Command{
for _, sector := range pending {
fmt.Println(sector.Number)
}
return nil
}

fmt.Println("No sectors queued to be committed")
reader := bufio.NewReader(os.Stdin)
fmt.Print("Do you want to publish these sectors now? (yes/no): ")
userInput, err := reader.ReadString('\n')
if err != nil {
return xerrors.Errorf("reading user input: %w", err)
}
userInput = strings.ToLower(strings.TrimSpace(userInput))

if userInput == "yes" {
err := cctx.Set("publish-now", "true")
if err != nil {
return xerrors.Errorf("setting publish-now flag: %w", err)
}
return cctx.Command.Action(cctx)
} else if userInput == "no" {
return nil
} else {
fmt.Println("Invalid input. Please answer with 'yes' or 'no'.")
return nil
}

} else {
fmt.Println("No sectors queued to be committed")
}
return nil
},
}
Expand Down Expand Up @@ -1980,10 +2001,31 @@ var sectorsBatchingPendingPreCommit = &cli.Command{
for _, sector := range pending {
fmt.Println(sector.Number)
}
return nil
}

fmt.Println("No sectors queued to be committed")
reader := bufio.NewReader(os.Stdin)
fmt.Print("Do you want to publish these sectors now? (yes/no): ")
userInput, err := reader.ReadString('\n')
if err != nil {
return xerrors.Errorf("reading user input: %w", err)
}
userInput = strings.ToLower(strings.TrimSpace(userInput))

if userInput == "yes" {
err := cctx.Set("publish-now", "true")
if err != nil {
return xerrors.Errorf("setting publish-now flag: %w", err)
}
return cctx.Command.Action(cctx)
} else if userInput == "no" {
return nil
} else {
fmt.Println("Invalid input. Please answer with 'yes' or 'no'.")
return nil
}

} else {
fmt.Println("No sectors queued to be committed")
}
return nil
},
}
Expand Down

0 comments on commit 5697645

Please sign in to comment.