diff --git a/cmd/delete.go b/cmd/delete.go index 53aabea4e7..1bb8de2e17 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -43,8 +43,9 @@ No local files are deleted. fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err) } - // Flag + // Flags cmd.Flags().BoolP("confirm", "c", cfg.Confirm, "Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)") + cmd.Flags().StringP("namespace", "n", cfg.Namespace, "The namespace in which to delete. (Env: $FUNC_NAMESPACE)") cmd.Flags().StringP("all", "a", "true", "Delete all resources created for a function, eg. Pipelines, Secrets, etc. (Env: $FUNC_ALL) (allowed values: \"true\", \"false\")") setPathFlag(cmd) diff --git a/cmd/info.go b/cmd/info.go index 20c7aa89ea..78dcbc5606 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -12,6 +12,7 @@ import ( "gopkg.in/yaml.v2" fn "knative.dev/func" + "knative.dev/func/config" ) func NewInfoCmd(newClient ClientFactory) *cobra.Command { @@ -35,7 +36,15 @@ the current directory or from the directory specified with --path. PreRunE: bindEnv("output", "path"), } + // Config + cfg, err := config.NewDefault() + if err != nil { + fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err) + } + + // Flags cmd.Flags().StringP("output", "o", "human", "Output format (human|plain|json|xml|yaml|url) (Env: $FUNC_OUTPUT)") + cmd.Flags().StringP("namespace", "n", cfg.Namespace, "The namespace in which to look for the named function. (Env: $FUNC_NAMESPACE)") setPathFlag(cmd) if err := cmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList); err != nil { diff --git a/cmd/list.go b/cmd/list.go index ba112b1ed8..147c823381 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -14,6 +14,7 @@ import ( "gopkg.in/yaml.v2" fn "knative.dev/func" + "knative.dev/func/config" ) func NewListCmd(newClient ClientFactory) *cobra.Command { @@ -38,7 +39,15 @@ Lists all deployed functions in a given namespace. PreRunE: bindEnv("all-namespaces", "output"), } + // Config + cfg, err := config.NewDefault() + if err != nil { + fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err) + } + + // Flags cmd.Flags().BoolP("all-namespaces", "A", false, "List functions in all namespaces. If set, the --namespace flag is ignored.") + cmd.Flags().StringP("namespace", "n", cfg.Namespace, "The namespace for which to list functions. (Env: $FUNC_NAMESPACE)") cmd.Flags().StringP("output", "o", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_OUTPUT)") if err := cmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList); err != nil { diff --git a/cmd/repository.go b/cmd/repository.go index 359a5fdf3d..32091aafa0 100644 --- a/cmd/repository.go +++ b/cmd/repository.go @@ -339,7 +339,6 @@ func runRepositoryAdd(_ *cobra.Command, args []string, newClient ClientFactory) // be created in XDG_CONFIG_HOME/func even if the repo path environment // was set to some other location on disk. client, done := newClient(ClientConfig{Verbose: cfg.Verbose}) - defer done() // Preconditions