Add subcommand prune to the container, volume, image and system commands

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure
2016-09-22 14:04:34 -07:00
parent 82dc15836b
commit 6f8bb41ecb
12 changed files with 396 additions and 3 deletions

View File

@ -57,3 +57,25 @@ func PrettyPrint(i interface{}) string {
return capitalizeFirst(fmt.Sprintf("%s", t))
}
}
// PromptForConfirmation request and check confirmation from user.
// This will display the provided message followed by ' [y/N] '. If
// the user input 'y' or 'Y' it returns true other false. If no
// message is provided "Are you sure you want to proceeed? [y/N] "
// will be used instead.
func PromptForConfirmation(ins *InStream, outs *OutStream, message string) bool {
if message == "" {
message = "Are you sure you want to proceeed?"
}
message += " [y/N] "
fmt.Fprintf(outs, message)
answer := ""
n, _ := fmt.Fscan(ins, &answer)
if n != 1 || (answer != "y" && answer != "Y") {
return false
}
return true
}