|
4 | 4 | package command
|
5 | 5 |
|
6 | 6 | import (
|
7 |
| - "context" |
8 |
| - "io" |
9 | 7 | "os"
|
10 | 8 | "path/filepath"
|
11 | 9 | "strings"
|
12 | 10 |
|
13 | 11 | "github.com/docker/cli/cli/config"
|
14 |
| - "github.com/docker/cli/cli/streams" |
15 |
| - "github.com/docker/cli/internal/prompt" |
16 | 12 | "github.com/moby/moby/api/types/filters"
|
17 | 13 | "github.com/pkg/errors"
|
18 | 14 | "github.com/spf13/pflag"
|
19 | 15 | )
|
20 | 16 |
|
21 |
| -const ErrPromptTerminated = prompt.ErrTerminated |
22 |
| - |
23 |
| -// DisableInputEcho disables input echo on the provided streams.In. |
24 |
| -// This is useful when the user provides sensitive information like passwords. |
25 |
| -// The function returns a restore function that should be called to restore the |
26 |
| -// terminal state. |
27 |
| -func DisableInputEcho(ins *streams.In) (restore func() error, err error) { |
28 |
| - return prompt.DisableInputEcho(ins) |
29 |
| -} |
30 |
| - |
31 |
| -// PromptForInput requests input from the user. |
32 |
| -// |
33 |
| -// If the user terminates the CLI with SIGINT or SIGTERM while the prompt is |
34 |
| -// active, the prompt will return an empty string ("") with an ErrPromptTerminated error. |
35 |
| -// When the prompt returns an error, the caller should propagate the error up |
36 |
| -// the stack and close the io.Reader used for the prompt which will prevent the |
37 |
| -// background goroutine from blocking indefinitely. |
38 |
| -func PromptForInput(ctx context.Context, in io.Reader, out io.Writer, message string) (string, error) { |
39 |
| - return prompt.ReadInput(ctx, in, out, message) |
40 |
| -} |
41 |
| - |
42 |
| -// PromptForConfirmation requests and checks confirmation from the user. |
43 |
| -// This will display the provided message followed by ' [y/N] '. If the user |
44 |
| -// input 'y' or 'Y' it returns true otherwise false. If no message is provided, |
45 |
| -// "Are you sure you want to proceed? [y/N] " will be used instead. |
46 |
| -// |
47 |
| -// If the user terminates the CLI with SIGINT or SIGTERM while the prompt is |
48 |
| -// active, the prompt will return false with an ErrPromptTerminated error. |
49 |
| -// When the prompt returns an error, the caller should propagate the error up |
50 |
| -// the stack and close the io.Reader used for the prompt which will prevent the |
51 |
| -// background goroutine from blocking indefinitely. |
52 |
| -func PromptForConfirmation(ctx context.Context, ins io.Reader, outs io.Writer, message string) (bool, error) { |
53 |
| - return prompt.Confirm(ctx, ins, outs, message) |
54 |
| -} |
55 |
| - |
56 | 17 | // PruneFilters merges prune filters specified in config.json with those specified
|
57 | 18 | // as command-line flags.
|
58 | 19 | //
|
|
0 commit comments