Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #155 from JackalLabs/JKL-416-yes-flag-to-skip-conf…
Browse files Browse the repository at this point in the history
…irmation

add skip confirmation flag to prune and migration cmd
  • Loading branch information
dahn510 authored Apr 22, 2024
2 parents 4bc75b6 + 9f2e899 commit b4273ee
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions jprov/jprovd/provider_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,18 @@ func PruneCommand() *cobra.Command {
Long: "Prune files that are no longer on contract according to chain data",
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
buf := bufio.NewReader(cmd.InOrStdin())
yes, err := input.GetConfirmation("Are you sure you want to prune expired files?", buf, cmd.ErrOrStderr())
if err != nil {
return err
}
if !cmd.Flags().Changed(flags.FlagSkipConfirmation) {
buf := bufio.NewReader(cmd.InOrStdin())
yes, err := input.GetConfirmation("Are you sure you want to prune expired files?", buf, cmd.ErrOrStderr())
if err != nil {
return err
}

if !yes {
return nil
}
if !yes {
return nil
}

}
clientCtx := client.GetClientContextFromCmd(cmd)

dbPath := utils.GetArchiveDBPath(clientCtx)
Expand Down Expand Up @@ -317,18 +319,21 @@ func MigrateCommand() *cobra.Command {
Args: cobra.ExactArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
prune, err := cmd.Flags().GetBool(types.FlagPruneFirst)
if err != nil {
return err
}

buf := bufio.NewReader(cmd.InOrStdin())
yes, err := input.GetConfirmation("Are you sure you want to migrate from old file system?", buf, cmd.ErrOrStderr())
if err != nil {
return err
}
if !cmd.Flags().Changed(flags.FlagSkipConfirmation) {
if err != nil {
return err
}

if !yes {
return nil
buf := bufio.NewReader(cmd.InOrStdin())
yes, err := input.GetConfirmation("Are you sure you want to migrate from old file system?", buf, cmd.ErrOrStderr())
if err != nil {
return err
}

if !yes {
return nil
}
}

defer func() {
Expand Down

0 comments on commit b4273ee

Please sign in to comment.