Merge pull request #10837 from filecoin-project/feat/ux-friendly-batch-cmd

feat: cli: More ux-friendly batching cmds
This commit is contained in:
Phi-rjan 2023-05-08 17:40:01 +02:00 committed by GitHub
commit 5697645748
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
},
}
@ -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
},
}