You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: default to no confirmation prompts for CLI commands
The CLI commands all printed confirmation prompts for the various flags
they exposed. This commit modifies that logic, so that there is no longer
a `-y` flag, but instead a `--confirm` or `-c` flag for each command, and
prompts are only displayed if using this flag. In most cases, the derived
values are printed even if not prompted for.
In call cases where the user is prompted, I have removed the "Verbose"
prompt, as that seems less like a configuration option that needs to be
confirmed, and more like just a CLI option for the current run which we
can just accept as-is.
The text for the prompts has also been reduced to one or two words.
Also added are some checks around image naming and repositories, short
circuiting failures that could occur if these are not specified or are
unknown. For example, if a user does `faas init` and then `faas deploy`
we don't yet know what the image name should be - one hasn't been built.
Fixes: #91Fixes: #90Fixes: #89
Copy file name to clipboardexpand all lines: cmd/build.go
+33-16
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
package cmd
2
2
3
3
import (
4
+
"fmt"
5
+
4
6
"github.com/ory/viper"
5
7
"github.com/spf13/cobra"
6
8
@@ -11,22 +13,37 @@ import (
11
13
12
14
funcinit() {
13
15
root.AddCommand(buildCmd)
16
+
buildCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options - $FAAS_CONFIRM")
14
17
buildCmd.Flags().StringP("image", "i", "", "Optional full image name, in form [registry]/[namespace]/[name]:[tag] for example quay.io/myrepo/project.name:latest (overrides --repository) - $FAAS_IMAGE")
15
18
buildCmd.Flags().StringP("path", "p", cwd(), "Path to the Function project directory - $FAAS_PATH")
16
19
buildCmd.Flags().StringP("repository", "r", "", "Repository for built images, ex 'docker.io/myuser' or just 'myuser'. Optional if --image provided. - $FAAS_REPOSITORY")
17
-
buildCmd.Flags().BoolP("yes", "y", false, "When in interactive mode (attached to a TTY) skip prompts. - $FAAS_YES")
18
20
}
19
21
20
22
varbuildCmd=&cobra.Command{
21
23
Use: "build [options]",
22
24
Short: "Build an existing Function project as an OCI image",
Copy file name to clipboardexpand all lines: cmd/create.go
+33-16
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ import (
4
4
"fmt"
5
5
"path/filepath"
6
6
7
+
"github.com/ory/viper"
7
8
"github.com/spf13/cobra"
8
9
9
10
"github.com/boson-project/faas"
@@ -16,14 +17,14 @@ import (
16
17
17
18
funcinit() {
18
19
root.AddCommand(createCmd)
20
+
createCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options - $FAAS_CONFIRM")
19
21
createCmd.Flags().StringP("image", "i", "", "Optional full image name, in form [registry]/[namespace]/[name]:[tag] for example quay.io/myrepo/project.name:latest (overrides --repository) - $FAAS_IMAGE")
20
22
createCmd.Flags().StringP("namespace", "n", "", "Override namespace into which the Function is deployed (on supported platforms). Default is to use currently active underlying platform setting - $FAAS_NAMESPACE")
21
23
createCmd.Flags().StringP("path", "p", cwd(), "Path to the new project directory - $FAAS_PATH")
22
24
createCmd.Flags().StringP("repository", "r", "", "Repository for built images, ex 'docker.io/myuser' or just 'myuser'. Optional if --image provided. - $FAAS_REPOSITORY")
Copy file name to clipboardexpand all lines: cmd/delete.go
+3-5
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@ import (
11
11
12
12
funcinit() {
13
13
root.AddCommand(deleteCmd)
14
+
deleteCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options - $FAAS_CONFIRM")
14
15
deleteCmd.Flags().StringP("path", "p", cwd(), "Path to the project which should be deleted - $FAAS_PATH")
15
16
deleteCmd.Flags().StringP("namespace", "n", "", "Override namespace in which to search for Functions. Default is to use currently active underlying platform setting - $FAAS_NAMESPACE")
16
-
deleteCmd.Flags().BoolP("yes", "y", false, "When in interactive mode (attached to a TTY), skip prompting the user. - $FAAS_YES")
17
17
}
18
18
19
19
vardeleteCmd=&cobra.Command{
@@ -22,7 +22,7 @@ var deleteCmd = &cobra.Command{
22
22
Long: `Removes the deployed Function by name, by explicit path, or by default for the current directory. No local files are deleted.`,
23
23
SuggestFor: []string{"remove", "rm", "del"},
24
24
ValidArgsFunction: CompleteFunctionList,
25
-
PreRunE: bindEnv("path", "yes", "namespace"),
25
+
PreRunE: bindEnv("path", "confirm", "namespace"),
26
26
RunE: runDelete,
27
27
}
28
28
@@ -46,7 +46,6 @@ type deleteConfig struct {
46
46
Namespacestring
47
47
Pathstring
48
48
Verbosebool
49
-
Yesbool
50
49
}
51
50
52
51
// newDeleteConfig returns a config populated from the current execution context
Copy file name to clipboardexpand all lines: cmd/deploy.go
+23-16
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
1
package cmd
2
2
3
3
import (
4
+
"fmt"
5
+
4
6
"github.com/ory/viper"
5
7
"github.com/spf13/cobra"
6
8
@@ -12,21 +14,31 @@ import (
12
14
13
15
funcinit() {
14
16
root.AddCommand(deployCmd)
17
+
deployCmd.Flags().BoolP("confirm", "c", false, "Prompt to confirm all configuration options - $FAAS_CONFIRM")
15
18
deployCmd.Flags().StringP("namespace", "n", "", "Override namespace into which the Function is deployed (on supported platforms). Default is to use currently active underlying platform setting - $FAAS_NAMESPACE")
16
19
deployCmd.Flags().StringP("path", "p", cwd(), "Path to the function project directory - $FAAS_PATH")
17
-
deployCmd.Flags().BoolP("yes", "y", false, "When in interactive mode (attached to a TTY) skip prompts. - $FAAS_YES")
18
20
}
19
21
20
22
vardeployCmd=&cobra.Command{
21
23
Use: "deploy",
22
24
Short: "Deploy an existing Function project to a cluster",
0 commit comments