cli help text updates and flags cleanup (#1564)

* cli help text and flags cleanup

- verbose flag uses global setting throughout
- confirm flag added using shared visitor throughout
- path flag added using shared visitor throughout
- removes --version flag on root as redundant with subcommand
- splits main help's 'Main Commands' into 'Primary Commands' and 'Development
  Commands' groups
- Moves RunE definition into flag struct literals

* remove commented code
This commit is contained in:
Luke Kingland 2023-03-01 18:35:54 +09:00 committed by GitHub
parent 9c5b5a805b
commit aa582dad21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 338 additions and 484 deletions

View File

@ -19,10 +19,10 @@ import (
func NewBuildCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "build",
Short: "Build a Function",
Short: "Build a function container",
Long: `
NAME
{{rootCmdUse}} build - Build a Function
{{rootCmdUse}} build - Build a function container locally withoud deploying
SYNOPSIS
{{rootCmdUse}} build [-r|--registry] [--builder] [--builder-image] [--push]
@ -64,7 +64,7 @@ EXAMPLES
`,
SuggestFor: []string{"biuld", "buidl", "built"},
PreRunE: bindEnv("image", "path", "builder", "registry", "confirm", "push", "builder-image", "platform"),
PreRunE: bindEnv("image", "path", "builder", "registry", "confirm", "push", "builder-image", "platform", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runBuild(cmd, args, newClient)
},
@ -94,8 +94,6 @@ EXAMPLES
// contextually relevant function; sets are flattened above via cfg.Apply(f)
cmd.Flags().StringP("builder", "b", cfg.Builder,
fmt.Sprintf("Builder to use when creating the function's container. Currently supported builders are %s. (Env: $FUNC_BUILDER)", KnownBuilders()))
cmd.Flags().BoolP("confirm", "c", cfg.Confirm,
"Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)")
cmd.Flags().StringP("registry", "r", cfg.Registry,
"Container registry + registry namespace. (ex 'ghcr.io/myuser'). The full image name is automatically determined using this along with function name. (Env: $FUNC_REGISTRY)")
@ -115,7 +113,11 @@ EXAMPLES
"Attempt to push the function image to the configured registry after being successfully built")
cmd.Flags().StringP("platform", "", "",
"Optionally specify a target platform, for example \"linux/amd64\" when using the s2i build strategy")
setPathFlag(cmd)
// Oft-shared flags:
addConfirmFlag(cmd, cfg.Confirm)
addPathFlag(cmd)
addVerboseFlag(cmd, cfg.Verbose)
// Tab Completion
if err := cmd.RegisterFlagCompletionFunc("builder", CompleteBuilderList); err != nil {

View File

@ -10,7 +10,7 @@ import (
func NewCompletionCmd() *cobra.Command {
return &cobra.Command{
Use: "completion <bash|zsh|fish>",
Short: "Generate completion scripts for bash, fish and zsh",
Short: "Output functions shell completion code",
Long: `To load completion run
For zsh:

View File

@ -7,6 +7,7 @@ import (
"github.com/ory/viper"
"github.com/spf13/cobra"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
)
@ -53,11 +54,16 @@ variables, and Labels for a function project present in the current directory
or from the directory specified with --path.
`,
SuggestFor: []string{"cfg", "cofnig"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: runConfigCmd,
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
setPathFlag(cmd)
addPathFlag(cmd)
addVerboseFlag(cmd, cfg.Verbose)
cmd.AddCommand(NewConfigLabelsCmd(loadSaver))
cmd.AddCommand(NewConfigEnvsCmd(loadSaver))

View File

@ -13,6 +13,7 @@ import (
"github.com/ory/viper"
"github.com/spf13/cobra"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
"knative.dev/func/pkg/utils"
@ -29,7 +30,7 @@ the current directory or from the directory specified with --path.
`,
Aliases: []string{"env"},
SuggestFor: []string{"ensv"},
PreRunE: bindEnv("path", "output"),
PreRunE: bindEnv("path", "output", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(loadSaver)
if err != nil {
@ -39,15 +40,23 @@ the current directory or from the directory specified with --path.
return listEnvs(function, cmd.OutOrStdout(), Format(viper.GetString("output")))
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
cmd.Flags().StringP("output", "o", "human", "Output format (human|json) (Env: $FUNC_OUTPUT)")
configEnvsAddCmd := NewConfigEnvsAddCmd(loadSaver)
configEnvsRemoveCmd := NewConfigEnvsRemoveCmd()
setPathFlag(cmd)
setPathFlag(configEnvsAddCmd)
setPathFlag(configEnvsRemoveCmd)
addPathFlag(cmd)
addPathFlag(configEnvsAddCmd)
addPathFlag(configEnvsRemoveCmd)
addVerboseFlag(cmd, cfg.Verbose)
addVerboseFlag(configEnvsAddCmd, cfg.Verbose)
addVerboseFlag(configEnvsRemoveCmd, cfg.Verbose)
cmd.AddCommand(configEnvsAddCmd)
cmd.AddCommand(configEnvsRemoveCmd)
@ -84,7 +93,7 @@ set environment variable from a secret
# set all key as environment variables from a configMap
{{rootCmdUse}} config envs add --value='{{"{{"}} configMap:confMapName {{"}}"}}'`,
SuggestFor: []string{"ad", "create", "insert", "append"},
PreRunE: bindEnv("path", "name", "value"),
PreRunE: bindEnv("path", "name", "value", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(loadSaver)
if err != nil {
@ -141,7 +150,7 @@ in the current directory or from the directory specified with --path.
`,
Aliases: []string{"rm"},
SuggestFor: []string{"del", "delete", "rmeove"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(defaultLoaderSaver)
if err != nil {

View File

@ -8,6 +8,7 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/spf13/cobra"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/utils"
)
@ -23,7 +24,7 @@ the current directory or from the directory specified with --path.
`,
Aliases: []string{"label"},
SuggestFor: []string{"albels", "abels"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(loaderSaver)
if err != nil {
@ -48,7 +49,7 @@ The label can be set directly from a value or from an environment variable on
the local machine.
`,
SuggestFor: []string{"ad", "create", "insert", "append"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(loaderSaver)
if err != nil {
@ -69,7 +70,7 @@ directory or from the directory specified with --path.
`,
Aliases: []string{"rm"},
SuggestFor: []string{"del", "delete", "rmeove"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(loaderSaver)
if err != nil {
@ -80,9 +81,18 @@ directory or from the directory specified with --path.
},
}
setPathFlag(configLabelsCmd)
setPathFlag(configLabelsAddCmd)
setPathFlag(configLabelsRemoveCmd)
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(configLabelsCmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
addPathFlag(configLabelsCmd)
addPathFlag(configLabelsAddCmd)
addPathFlag(configLabelsRemoveCmd)
addVerboseFlag(configLabelsCmd, cfg.Verbose)
addVerboseFlag(configLabelsAddCmd, cfg.Verbose)
addVerboseFlag(configLabelsRemoveCmd, cfg.Verbose)
configLabelsCmd.AddCommand(configLabelsAddCmd)
configLabelsCmd.AddCommand(configLabelsRemoveCmd)

View File

@ -8,6 +8,7 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/spf13/cobra"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
)
@ -23,7 +24,7 @@ the current directory or from the directory specified with --path.
`,
Aliases: []string{"volume"},
SuggestFor: []string{"vol", "volums", "vols"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(defaultLoaderSaver)
if err != nil {
@ -35,13 +36,21 @@ the current directory or from the directory specified with --path.
return
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
configVolumesAddCmd := NewConfigVolumesAddCmd()
configVolumesRemoveCmd := NewConfigVolumesRemoveCmd()
setPathFlag(cmd)
setPathFlag(configVolumesAddCmd)
setPathFlag(configVolumesRemoveCmd)
addPathFlag(cmd)
addPathFlag(configVolumesAddCmd)
addPathFlag(configVolumesRemoveCmd)
addVerboseFlag(cmd, cfg.Verbose)
addVerboseFlag(configVolumesAddCmd, cfg.Verbose)
addVerboseFlag(configVolumesRemoveCmd, cfg.Verbose)
cmd.AddCommand(configVolumesAddCmd)
cmd.AddCommand(configVolumesRemoveCmd)
@ -59,7 +68,7 @@ Interactive prompt to add Secrets and ConfigMaps as Volume mounts to the functio
in the current directory or from the directory specified with --path.
`,
SuggestFor: []string{"ad", "create", "insert", "append"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(defaultLoaderSaver)
if err != nil {
@ -84,7 +93,7 @@ in the current directory or from the directory specified with --path.
`,
Aliases: []string{"rm"},
SuggestFor: []string{"del", "delete", "rmeove"},
PreRunE: bindEnv("path"),
PreRunE: bindEnv("path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) (err error) {
function, err := initConfigCommand(defaultLoaderSaver)
if err != nil {

View File

@ -30,10 +30,10 @@ type ErrInvalidTemplate error
func NewCreateCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "Create a function project",
Short: "Create a function",
Long: `
NAME
{{.Name}} create - Create a function project.
{{.Name}} create - Create a function
SYNOPSIS
{{.Name}} create [-l|--language] [-t|--template] [-r|--repository]
@ -72,8 +72,11 @@ EXAMPLES
$ {{.Name}} create -l go -t cloudevents myfunc
`,
SuggestFor: []string{"vreate", "creaet", "craete", "new"},
PreRunE: bindEnv("language", "template", "repository", "confirm"),
PreRunE: bindEnv("language", "template", "repository", "confirm", "verbose"),
Aliases: []string{"init"},
RunE: func(cmd *cobra.Command, args []string) error {
return runCreate(cmd, args, newClient)
},
}
// Config
@ -86,16 +89,14 @@ EXAMPLES
cmd.Flags().StringP("language", "l", cfg.Language, "Language Runtime (see help text for list) (Env: $FUNC_LANGUAGE)")
cmd.Flags().StringP("template", "t", fn.DefaultTemplate, "Function template. (see help text for list) (Env: $FUNC_TEMPLATE)")
cmd.Flags().StringP("repository", "r", "", "URI to a Git repository containing the specified template (Env: $FUNC_REPOSITORY)")
cmd.Flags().BoolP("confirm", "c", cfg.Confirm, "Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)")
addConfirmFlag(cmd, cfg.Confirm)
// TODO: refactor to use --path like all the other commands
addVerboseFlag(cmd, cfg.Verbose)
// Help Action
cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { runCreateHelp(cmd, args, newClient) })
// Run Action
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runCreate(cmd, args, newClient)
}
// Tab completion
if err := cmd.RegisterFlagCompletionFunc("language", newRuntimeCompletionFunc(newClient)); err != nil {
fmt.Fprintf(os.Stderr, "unable to provide language runtime suggestions: %v", err)

View File

@ -32,8 +32,11 @@ No local files are deleted.
`,
SuggestFor: []string{"remove", "rm", "del"},
ValidArgsFunction: CompleteFunctionList,
PreRunE: bindEnv("path", "confirm", "all", "namespace"),
PreRunE: bindEnv("path", "confirm", "all", "namespace", "verbose"),
SilenceUsage: true, // no usage dump on error
RunE: func(cmd *cobra.Command, args []string) error {
return runDelete(cmd, args, newClient)
},
}
// Config
@ -43,14 +46,11 @@ No local files are deleted.
}
// 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)
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runDelete(cmd, args, newClient)
}
addConfirmFlag(cmd, cfg.Confirm)
addPathFlag(cmd)
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}

View File

@ -30,10 +30,10 @@ import (
func NewDeployCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "deploy",
Short: "Deploy a Function",
Short: "Deploy a function",
Long: `
NAME
{{rootCmdUse}} deploy - Deploy a Function
{{rootCmdUse}} deploy - Deploy a function
SYNOPSIS
{{rootCmdUse}} deploy [-R|--remote] [-r|--registry] [-i|--image] [-n|--namespace]
@ -123,7 +123,7 @@ EXAMPLES
`,
SuggestFor: []string{"delpoy", "deplyo"},
PreRunE: bindEnv("confirm", "env", "git-url", "git-branch", "git-dir", "remote", "build", "builder", "builder-image", "image", "registry", "push", "platform", "path", "namespace"),
PreRunE: bindEnv("confirm", "env", "git-url", "git-branch", "git-dir", "remote", "build", "builder", "builder-image", "image", "registry", "push", "platform", "namespace", "path", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runDeploy(cmd, newClient)
},
@ -148,8 +148,6 @@ EXAMPLES
// contextually relevant function; but sets are flattened via cfg.Apply(f)
cmd.Flags().StringP("builder", "b", cfg.Builder,
fmt.Sprintf("Builder to use when creating the function's container. Currently supported builders are %s.", KnownBuilders()))
cmd.Flags().BoolP("confirm", "c", cfg.Confirm,
"Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)")
cmd.Flags().StringP("registry", "r", cfg.Registry,
"Container registry + registry namespace. (ex 'ghcr.io/myuser'). The full image name is automatically determined using this along with function name. (Env: $FUNC_REGISTRY)")
cmd.Flags().StringP("namespace", "n", cfg.Namespace,
@ -185,7 +183,11 @@ EXAMPLES
"Push the function image to registry before deploying. (Env: $FUNC_PUSH)")
cmd.Flags().StringP("platform", "", "",
"Optionally specify a specific platform to build for (e.g. linux/amd64). (Env: $FUNC_PLATFORM)")
setPathFlag(cmd)
// Oft-shared flags:
addConfirmFlag(cmd, cfg.Confirm)
addPathFlag(cmd)
addVerboseFlag(cmd, cfg.Verbose)
// Tab Completion
if err := cmd.RegisterFlagCompletionFunc("builder", CompleteBuilderList); err != nil {

View File

@ -18,8 +18,8 @@ import (
func NewDescribeCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "describe <name>",
Short: "Describe a Function",
Long: `Describe a Function
Short: "Describe a function",
Long: `Describe a function
Prints the name, route and event subscriptions for a deployed function in
the current directory or from the directory specified with --path.
@ -35,7 +35,10 @@ the current directory or from the directory specified with --path.
ValidArgsFunction: CompleteFunctionList,
Aliases: []string{"info", "desc"},
PreRunE: bindEnv("output", "path", "namespace"),
PreRunE: bindEnv("output", "path", "namespace", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runDescribe(cmd, args, newClient)
},
}
// Config
@ -47,16 +50,13 @@ the current directory or from the directory specified with --path.
// 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)
addPathFlag(cmd)
addVerboseFlag(cmd, cfg.Verbose)
if err := cmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList); err != nil {
fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err)
}
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runDescribe(cmd, args, newClient)
}
return cmd
}

View File

@ -18,7 +18,7 @@ import (
func NewInvokeCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "invoke",
Short: "Invoke a function",
Short: "Invoke a local or remote function",
Long: `
NAME
{{rootCmdUse}} invoke - test a function by invoking it with test data
@ -102,7 +102,10 @@ EXAMPLES
`,
SuggestFor: []string{"emit", "emti", "send", "emit", "exec", "nivoke", "onvoke", "unvoke", "knvoke", "imvoke", "ihvoke", "ibvoke"},
PreRunE: bindEnv("path", "format", "target", "id", "source", "type", "data", "content-type", "file", "insecure", "confirm"),
PreRunE: bindEnv("path", "format", "target", "id", "source", "type", "data", "content-type", "file", "insecure", "confirm", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runInvoke(cmd, args, newClient)
},
}
// Config
@ -112,7 +115,6 @@ EXAMPLES
}
// Flags
setPathFlag(cmd)
cmd.Flags().StringP("format", "f", "", "Format of message to send, 'http' or 'cloudevent'. Default is to choose automatically. (Env: $FUNC_FORMAT)")
cmd.Flags().StringP("target", "t", "", "Function instance to invoke. Can be 'local', 'remote' or a URL. Defaults to auto-discovery if not provided. (Env: $FUNC_TARGET)")
cmd.Flags().StringP("id", "", "", "ID for the request data. (Env: $FUNC_ID)")
@ -122,11 +124,9 @@ EXAMPLES
cmd.Flags().StringP("data", "", fn.DefaultInvokeData, "Data to send in the request. (Env: $FUNC_DATA)")
cmd.Flags().StringP("file", "", "", "Path to a file to use as data. Overrides --data flag and should be sent with a correct --content-type. (Env: $FUNC_FILE)")
cmd.Flags().BoolP("insecure", "i", false, "Allow insecure server connections when using SSL. (Env: $FUNC_INSECURE)")
cmd.Flags().BoolP("confirm", "c", cfg.Confirm, "Prompt to confirm all options interactively. (Env: $FUNC_CONFIRM)")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runInvoke(cmd, args, newClient)
}
addConfirmFlag(cmd, cfg.Confirm)
addPathFlag(cmd)
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}

View File

@ -7,6 +7,7 @@ import (
"github.com/ory/viper"
"github.com/spf13/cobra"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
)
@ -49,15 +50,21 @@ EXAMPLES
`,
SuggestFor: []string{"language", "runtime", "runtimes", "lnaguages", "languagse",
"panguages", "manguages", "kanguages", "lsnguages", "lznguages"},
PreRunE: bindEnv("json", "repository"),
PreRunE: bindEnv("json", "repository", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runLanguages(cmd, args, newClient)
},
}
// Global Config
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
cmd.Flags().BoolP("json", "", false, "Set output to JSON format. (Env: $FUNC_JSON)")
cmd.Flags().StringP("repository", "r", "", "URI to a specific repository to consider (Env: $FUNC_REPOSITORY)")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runLanguages(cmd, args, newClient)
}
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}

View File

@ -20,8 +20,8 @@ import (
func NewListCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List functions",
Long: `List functions
Short: "List deployed functions",
Long: `List deployed functions
Lists all deployed functions in a given namespace.
`,
@ -36,7 +36,15 @@ Lists all deployed functions in a given namespace.
{{rootCmdUse}} list --all-namespaces --output json
`,
SuggestFor: []string{"ls", "lsit"},
PreRunE: bindEnv("all-namespaces", "output", "namespace"),
PreRunE: bindEnv("all-namespaces", "output", "namespace", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runList(cmd, args, newClient)
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
// Namespace Config
@ -53,15 +61,12 @@ Lists all deployed functions in a given namespace.
cmd.Flags().BoolP("all-namespaces", "A", false, "List functions in all namespaces. If set, the --namespace flag is ignored.")
cmd.Flags().StringP("namespace", "n", config.DefaultNamespace(), "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)")
addVerboseFlag(cmd, cfg.Verbose)
if err := cmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList); err != nil {
fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err)
}
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runList(cmd, args, newClient)
}
return cmd
}

View File

@ -146,21 +146,18 @@ EXAMPLES
default
`,
SuggestFor: []string{"repositories", "repos", "template", "templates", "pack", "packs"},
PreRunE: bindEnv("confirm"),
PreRunE: bindEnv("confirm", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runRepository(cmd, args, newClient)
},
}
// 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("confirm", "c", cfg.Confirm, "Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runRepository(cmd, args, newClient)
}
addConfirmFlag(cmd, cfg.Confirm)
addVerboseFlag(cmd, cfg.Verbose)
cmd.AddCommand(NewRepositoryListCmd(newClient))
cmd.AddCommand(NewRepositoryAddCmd(newClient))
@ -175,11 +172,18 @@ func NewRepositoryListCmd(newClient ClientFactory) *cobra.Command {
Short: "List repositories",
Use: "list",
Aliases: []string{"ls"},
PreRunE: bindEnv("confirm", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runRepositoryList(cmd, args, newClient)
},
}
cmd.RunE = func(_ *cobra.Command, args []string) error {
return runRepositoryList(cmd, args, newClient)
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
addConfirmFlag(cmd, cfg.Confirm)
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}
@ -189,19 +193,18 @@ func NewRepositoryAddCmd(newClient ClientFactory) *cobra.Command {
Short: "Add a repository",
Use: "add <name> <url>",
SuggestFor: []string{"ad", "install"},
PreRunE: bindEnv("confirm"),
PreRunE: bindEnv("confirm", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runRepositoryAdd(cmd, args, newClient)
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
cmd.Flags().BoolP("confirm", "c", cfg.Confirm, "Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runRepositoryAdd(cmd, args, newClient)
}
addConfirmFlag(cmd, cfg.Confirm)
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}
@ -211,19 +214,18 @@ func NewRepositoryRenameCmd(newClient ClientFactory) *cobra.Command {
Short: "Rename a repository",
Use: "rename <old> <new>",
Aliases: []string{"mv"},
PreRunE: bindEnv("confirm"),
PreRunE: bindEnv("confirm", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runRepositoryRename(cmd, args, newClient)
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
cmd.Flags().BoolP("confirm", "c", cfg.Confirm, "Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runRepositoryRename(cmd, args, newClient)
}
addConfirmFlag(cmd, cfg.Confirm)
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}
@ -234,19 +236,18 @@ func NewRepositoryRemoveCmd(newClient ClientFactory) *cobra.Command {
Use: "remove <name>",
Aliases: []string{"rm"},
SuggestFor: []string{"delete", "del"},
PreRunE: bindEnv("confirm"),
PreRunE: bindEnv("confirm", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runRepositoryRemove(cmd, args, newClient)
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
cmd.Flags().BoolP("confirm", "c", cfg.Confirm, "Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runRepositoryRemove(cmd, args, newClient)
}
addConfirmFlag(cmd, cfg.Confirm)
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}

View File

@ -32,34 +32,22 @@ type RootCommandConfig struct {
// resultant binary with no arguments prints the help/usage text.
func NewRootCmd(cfg RootCommandConfig) *cobra.Command {
cmd := &cobra.Command{
// Use must be set to exactly config.Name, as this field is overloaded to
// be used in subcommand help text as the command with possible prefix:
Use: cfg.Name,
Short: "Serverless functions",
SilenceErrors: true, // we explicitly handle errors in Execute()
SilenceUsage: true, // no usage dump on error
Long: `Knative serverless functions
Use: cfg.Name,
Short: fmt.Sprintf("%s manages Knative Functions", cfg.Name),
Long: fmt.Sprintf(`%s is the command line interface for managing Knative Function resources
Create, build and deploy Knative functions
Create a new Node.js function in the current directory:
{{.Use}} create --language node myfunction
SYNOPSIS
{{.Use}} [-v|--verbose] <command> [args]
Deploy the function using Docker hub to host the image:
{{.Use}} deploy --registry docker.io/alice
EXAMPLES
Learn more about Functions: https://knative.dev/docs/functions/
Learn more about Knative at: https://knative.dev`, cfg.Name),
o Create a Node function in the current directory
$ {{.Use}} create --language node .
o Deploy the function defined in the current working directory to the
currently connected cluster, specifying a container registry in place of
quay.io/user for the function's container.
$ {{.Use}} deploy --registry quay.io.user
o Invoke the function defined in the current working directory with an example
request.
$ {{.Use}} invoke
For more examples, see '{{.Use}} [command] --help'.`,
DisableAutoGenTag: true, // no docs header
SilenceUsage: true, // no usage dump on error
SilenceErrors: true, // we explicitly handle errors in Execute()
}
// Environment Variables
@ -68,20 +56,6 @@ EXAMPLES
viper.AutomaticEnv() // read in environment variables for FUNC_<flag>
viper.SetEnvPrefix("func") // ensure that all have the prefix
// Flags
// persistent flags are available to all subcommands implicitly
// Note they are bound immediately here as opposed to other subcommands
// because this root command is not actually executed during tests, and
// therefore PreRunE and other event-based listeners are not invoked.
cmd.PersistentFlags().BoolP("verbose", "v", false, "Print verbose logs ($FUNC_VERBOSE)")
if err := viper.BindPFlag("verbose", cmd.PersistentFlags().Lookup("verbose")); err != nil {
fmt.Fprintf(os.Stderr, "error binding flag: %v\n", err)
}
// Version
cmd.Version = cfg.Version.String()
cmd.SetVersionTemplate(`{{printf "%s\n" .Version}}`)
// Client
// Use the provided ClientFactory or default to NewClient
newClient := cfg.NewClient
@ -92,20 +66,30 @@ EXAMPLES
// Grouped commands
groups := templates.CommandGroups{
{
Header: "Main Commands:",
Header: "Primary Commands:",
Commands: []*cobra.Command{
NewBuildCmd(newClient),
NewConfigCmd(defaultLoaderSaver),
NewCreateCmd(newClient),
NewDeleteCmd(newClient),
NewDeployCmd(newClient),
NewDescribeCmd(newClient),
NewInvokeCmd(newClient),
NewLanguagesCmd(newClient),
NewDeployCmd(newClient),
NewDeleteCmd(newClient),
NewListCmd(newClient),
NewRepositoryCmd(newClient),
},
},
{
Header: "Development Commands:",
Commands: []*cobra.Command{
NewRunCmd(newClient),
NewInvokeCmd(newClient),
NewBuildCmd(newClient),
},
},
{
Header: "System Commands:",
Commands: []*cobra.Command{
NewConfigCmd(defaultLoaderSaver),
NewLanguagesCmd(newClient),
NewTemplatesCmd(newClient),
NewRepositoryCmd(newClient),
},
},
{
@ -320,9 +304,19 @@ func mergeEnvs(envs []fn.Env, envToUpdate *util.OrderedMap, envToRemove []string
return envs, counter, nil
}
// setPathFlag ensures common text/wording when the --path flag is used
func setPathFlag(cmd *cobra.Command) {
cmd.Flags().StringP("path", "p", "", "Path to the project directory. Default is current working directory (Env: $FUNC_PATH)")
// addConfirmFlag ensures common text/wording when the --path flag is used
func addConfirmFlag(cmd *cobra.Command, dflt bool) {
cmd.Flags().BoolP("confirm", "c", dflt, "Prompt to confirm options interactively (Env: $FUNC_CONFIRM)")
}
// addPathFlag ensures common text/wording when the --path flag is used
func addPathFlag(cmd *cobra.Command) {
cmd.Flags().StringP("path", "p", "", "Path to the function. Default is current directory (Env: $FUNC_PATH)")
}
// addVerboseFlag ensures common text/wording when the --path flag is used
func addVerboseFlag(cmd *cobra.Command, dflt bool) {
cmd.Flags().BoolP("verbose", "v", false, "Print verbose logs ($FUNC_VERBOSE)")
}
// cwd returns the current working directory or exits 1 printing the error.

View File

@ -19,60 +19,6 @@ import (
const TestRegistry = "example.com/alice"
func TestRoot_PersistentFlags(t *testing.T) {
tests := []struct {
name string
args []string
expected bool
}{
{
name: "not provided",
args: []string{"list"},
expected: false,
},
{
name: "provided as root flags",
args: []string{"--verbose", "list"},
expected: true,
},
{
name: "provided as sub-command flags",
args: []string{"list", "--verbose"},
expected: true,
},
{
name: "provided as sub-sub-command flags",
args: []string{"repositories", "list", "--verbose"},
expected: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_ = fromTempDirectory(t)
cmd := NewCreateCmd(NewClient) // Create a function
cmd.SetArgs([]string{"--language", "go", "myfunc"}) // providing language
if err := cmd.Execute(); err != nil { // fail on any errors
t.Fatal(err)
}
// Assert the persistent variables were propagated to the Client constructor
// when the command is actually invoked.
cmd = NewRootCmd(RootCommandConfig{NewClient: func(cfg ClientConfig, _ ...fn.Option) (*fn.Client, func()) {
if cfg.Verbose != tt.expected {
t.Fatal("verbose persistent flag not propagated correctly")
}
return fn.New(), func() {}
}})
cmd.SetArgs(tt.args)
if err := cmd.Execute(); err != nil {
t.Fatal(err)
}
})
}
}
func TestRoot_mergeEnvMaps(t *testing.T) {
a := "A"
@ -186,7 +132,7 @@ func TestRoot_mergeEnvMaps(t *testing.T) {
// of the root command. This allows, for example, to have help text correct
// when both embedded as a plugin or standalone.
func TestRoot_CommandNameParameterized(t *testing.T) {
expectedSynopsis := "%v [-v|--verbose] <command> [args]"
expectedSynopsis := "%v is the command line interface for"
tests := []string{
"func", // standalone
@ -206,7 +152,7 @@ func TestRoot_CommandNameParameterized(t *testing.T) {
if cmd.Use != testName {
t.Fatalf("expected command Use '%v', got '%v'", testName, cmd.Use)
}
if !strings.Contains(out.String(), fmt.Sprintf(expectedSynopsis, testName)) {
if !strings.HasPrefix(out.String(), fmt.Sprintf(expectedSynopsis, testName)) {
t.Logf("Testing '%v'\n", testName)
t.Log(out.String())
t.Fatalf("Help text does not include substituted name '%v'", testName)
@ -233,12 +179,6 @@ func TestVerbose(t *testing.T) {
want: "v0.42.0",
wantLF: 1,
},
{
name: "verbose as root's flag",
args: []string{"--verbose", "version"},
want: "Version: v0.42.0-cafe-1970-01-01",
wantLF: 3,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

View File

@ -10,6 +10,7 @@ import (
"github.com/spf13/cobra"
"knative.dev/client/pkg/util"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
)
@ -43,7 +44,15 @@ to the function's source. Use --build to override this behavior.
`,
SuggestFor: []string{"rnu"},
PreRunE: bindEnv("build", "path", "registry"),
PreRunE: bindEnv("build", "path", "registry", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runRun(cmd, args, newClient)
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
cmd.Flags().StringArrayP("env", "e", []string{},
@ -53,11 +62,8 @@ to the function's source. Use --build to override this behavior.
cmd.Flags().StringP("build", "b", "auto", "Build the function. [auto|true|false].")
cmd.Flags().Lookup("build").NoOptDefVal = "true" // --build is equivalient to --build=true
cmd.Flags().StringP("registry", "r", "", "Registry + namespace part of the image if building, ex 'quay.io/myuser' (Env: $FUNC_REGISTRY)")
setPathFlag(cmd)
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runRun(cmd, args, newClient)
}
addPathFlag(cmd)
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}

View File

@ -11,6 +11,7 @@ import (
"github.com/ory/viper"
"github.com/spf13/cobra"
"knative.dev/func/pkg/config"
fn "knative.dev/func/pkg/functions"
)
@ -20,10 +21,10 @@ var ErrTemplateRepoDoesNotExist = errors.New("template repo does not exist")
func NewTemplatesCmd(newClient ClientFactory) *cobra.Command {
cmd := &cobra.Command{
Use: "templates",
Short: "Templates",
Short: "List available function source templates",
Long: `
NAME
{{rootCmdUse}} templates - list available templates
{{rootCmdUse}} templates - list available function source templates
SYNOPSIS
{{rootCmdUse}} templates [language] [--json] [-r|--repository]
@ -60,15 +61,20 @@ EXAMPLES
"temolates", "temllates", "temppates", "tempmates", "tempkates",
"templstes", "templztes", "templqtes", "templares", "templages", //nolint:misspell
"templayes", "templatee", "templatea", "templated", "templatew"},
PreRunE: bindEnv("json", "repository"),
PreRunE: bindEnv("json", "repository", "verbose"),
RunE: func(cmd *cobra.Command, args []string) error {
return runTemplates(cmd, args, newClient)
},
}
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
cmd.Flags().Bool("json", false, "Set output to JSON format. (Env: $FUNC_JSON)")
cmd.Flags().StringP("repository", "r", "", "URI to a specific repository to consider (Env: $FUNC_REPOSITORY)")
cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runTemplates(cmd, args, newClient)
}
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}

View File

@ -125,7 +125,7 @@ func validateRootUsageOutput(t *testing.T, stdOut string) {
assert.Assert(t, util.ContainsAll(stdOut, "header-1", "g1.1", "desc-g1.1", "g1.2", "desc-g1.2"))
assert.Assert(t, util.ContainsAll(stdOut, "header-2", "g2.1", "desc-g2.1", "g2.2", "desc-g2.2", "g2.3", "desc-g2.3"))
assert.Assert(t, util.ContainsAll(stdOut, "Use", "root", "--help"))
assert.Assert(t, util.ContainsAll(stdOut, "Use", "root", "[command]"))
assert.Assert(t, util.ContainsAll(stdOut, "Use", "root", "<command>"))
}
func validateSubUsageOutput(t *testing.T, stdOut string, cmd *cobra.Command) {

View File

@ -25,7 +25,7 @@ import (
const (
// sectionUsage is the help template section that displays the command's usage.
sectionUsage = `{{if (ne .UseLine "")}}Usage:
sectionUsage = `{{if and .Runnable (ne .UseLine "") (not (isRootCmd .))}}Usage:
{{useLine .}}
{{end}}`
@ -65,7 +65,7 @@ const (
{{end}}`
// sectionTipsHelp is the help template section that displays the '--help' hint.
sectionTipsHelp = `{{if .HasSubCommands}}Use "{{rootCmdName}} [command] --help" for more information about a given command.
sectionTipsHelp = `{{if .HasSubCommands}}Use "{{rootCmdName}} <command> --help" for more information about a given command.
{{end}}`
)

View File

@ -5,12 +5,13 @@ import (
"github.com/ory/viper"
"github.com/spf13/cobra"
"knative.dev/func/pkg/config"
)
func NewVersionCmd(version Version) *cobra.Command {
cmd := &cobra.Command{
Use: "version",
Short: "Show the version",
Short: "Function client version information",
Long: `
NAME
{{rootCmdUse}} version - function version information.
@ -31,12 +32,15 @@ DESCRIPTION
`,
SuggestFor: []string{"vers", "verison"}, //nolint:misspell
PreRunE: bindEnv("verbose"),
Run: func(cmd *cobra.Command, args []string) {
runVersion(cmd, args, version)
},
}
// Run Action
cmd.Run = func(cmd *cobra.Command, args []string) {
runVersion(cmd, args, version)
cfg, err := config.NewDefault()
if err != nil {
fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err)
}
addVerboseFlag(cmd, cfg.Verbose)
return cmd
}

View File

@ -1,53 +1,40 @@
## func
Serverless functions
func manages Knative Functions
### Synopsis
Knative serverless functions
func is the command line interface for managing Knative Function resources
Create, build and deploy Knative functions
Create a new Node.js function in the current directory:
func create --language node myfunction
SYNOPSIS
func [-v|--verbose] <command> [args]
Deploy the function using Docker hub to host the image:
func deploy --registry docker.io/alice
EXAMPLES
o Create a Node function in the current directory
$ func create --language node .
o Deploy the function defined in the current working directory to the
currently connected cluster, specifying a container registry in place of
quay.io/user for the function's container.
$ func deploy --registry quay.io.user
o Invoke the function defined in the current working directory with an example
request.
$ func invoke
For more examples, see 'func [command] --help'.
Learn more about Functions: https://knative.dev/docs/functions/
Learn more about Knative at: https://knative.dev
### Options
```
-h, --help help for func
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-h, --help help for func
```
### SEE ALSO
* [func build](func_build.md) - Build a Function
* [func completion](func_completion.md) - Generate completion scripts for bash, fish and zsh
* [func build](func_build.md) - Build a function container
* [func completion](func_completion.md) - Output functions shell completion code
* [func config](func_config.md) - Configure a function
* [func create](func_create.md) - Create a function project
* [func create](func_create.md) - Create a function
* [func delete](func_delete.md) - Undeploy a function
* [func deploy](func_deploy.md) - Deploy a Function
* [func describe](func_describe.md) - Describe a Function
* [func invoke](func_invoke.md) - Invoke a function
* [func deploy](func_deploy.md) - Deploy a function
* [func describe](func_describe.md) - Describe a function
* [func invoke](func_invoke.md) - Invoke a local or remote function
* [func languages](func_languages.md) - List available function language runtimes
* [func list](func_list.md) - List functions
* [func list](func_list.md) - List deployed functions
* [func repository](func_repository.md) - Manage installed template repositories
* [func run](func_run.md) - Run the function locally
* [func templates](func_templates.md) - Templates
* [func version](func_version.md) - Show the version
* [func templates](func_templates.md) - List available function source templates
* [func version](func_version.md) - Function client version information

View File

@ -1,12 +1,12 @@
## func build
Build a Function
Build a function container
### Synopsis
NAME
func build - Build a Function
func build - Build a function container locally withoud deploying
SYNOPSIS
func build [-r|--registry] [--builder] [--builder-image] [--push]
@ -57,22 +57,17 @@ func build
```
-b, --builder string Builder to use when creating the function's container. Currently supported builders are "pack" and "s2i". (Env: $FUNC_BUILDER) (default "pack")
--builder-image string Specify a custom builder image for use by the builder other than its default. (Env: $FUNC_BUILDER_IMAGE)
-c, --confirm Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for build
-i, --image string Full image name in the form [registry]/[namespace]/[name]:[tag] (optional). This option takes precedence over --registry (Env: $FUNC_IMAGE)
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
--platform string Optionally specify a target platform, for example "linux/amd64" when using the s2i build strategy
-u, --push Attempt to push the function image to the configured registry after being successfully built
-r, --registry string Container registry + registry namespace. (ex 'ghcr.io/myuser'). The full image name is automatically determined using this along with function name. (Env: $FUNC_REGISTRY)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -1,6 +1,6 @@
## func completion
Generate completion scripts for bash, fish and zsh
Output functions shell completion code
### Synopsis
@ -28,13 +28,7 @@ func completion <bash|zsh|fish>
-h, --help help for completion
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -19,18 +19,13 @@ func config
```
-h, --help help for config
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions
* [func config envs](func_config_envs.md) - List and manage configured environment variable for a function
* [func config labels](func_config_labels.md) - List and manage configured labels for a function
* [func config volumes](func_config_volumes.md) - List and manage configured volumes for a function

View File

@ -19,13 +19,8 @@ func config envs
```
-h, --help help for envs
-o, --output string Output format (human|json) (Env: $FUNC_OUTPUT) (default "human")
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -43,14 +43,9 @@ func config envs add --value='{{ configMap:confMapName }}'
```
-h, --help help for add
--name string Name of the environment variable.
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
--value string Value of the environment variable.
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -18,13 +18,8 @@ func config envs remove
```
-h, --help help for remove
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -18,13 +18,8 @@ func config labels
```
-h, --help help for labels
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -21,13 +21,8 @@ func config labels add
```
-h, --help help for add
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -18,13 +18,8 @@ func config labels remove
```
-h, --help help for remove
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -18,13 +18,8 @@ func config volumes
```
-h, --help help for volumes
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -18,13 +18,8 @@ func config volumes add
```
-h, --help help for add
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -18,13 +18,8 @@ func config volumes remove
```
-h, --help help for remove
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO

View File

@ -1,12 +1,12 @@
## func create
Create a function project
Create a function
### Synopsis
NAME
func create - Create a function project.
func create - Create a function
SYNOPSIS
func create [-l|--language] [-t|--template] [-r|--repository]
@ -68,20 +68,15 @@ func create
### Options
```
-c, --confirm Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for create
-l, --language string Language Runtime (see help text for list) (Env: $FUNC_LANGUAGE)
-r, --repository string URI to a Git repository containing the specified template (Env: $FUNC_REPOSITORY)
-t, --template string Function template. (see help text for list) (Env: $FUNC_TEMPLATE) (default "http")
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -33,19 +33,14 @@ func delete -n apps myfunc
```
-a, --all string Delete all resources created for a function, eg. Pipelines, Secrets, etc. (Env: $FUNC_ALL) (allowed values: "true", "false") (default "true")
-c, --confirm Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for delete
-n, --namespace string The namespace in which to delete. (Env: $FUNC_NAMESPACE)
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -1,12 +1,12 @@
## func deploy
Deploy a Function
Deploy a function
### Synopsis
NAME
func deploy - Deploy a Function
func deploy - Deploy a function
SYNOPSIS
func deploy [-R|--remote] [-r|--registry] [-i|--image] [-n|--namespace]
@ -106,7 +106,7 @@ func deploy
--build string[="true"] Build the function. [auto|true|false]. (Env: $FUNC_BUILD) (default "auto")
-b, --builder string Builder to use when creating the function's container. Currently supported builders are "pack" and "s2i". (default "pack")
--builder-image string Specify a custom builder image for use by the builder other than its default. ($FUNC_BUILDER_IMAGE)
-c, --confirm Prompt to confirm all configuration options (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-e, --env stringArray Environment variable to set in the form NAME=VALUE. You may provide this flag multiple times for setting multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
-t, --git-branch string Git revision (branch) to be used when deploying via a git repository (Env: $FUNC_GIT_BRANCH)
-d, --git-dir string Directory in the repo to find the function (default is the root) (Env: $FUNC_GIT_DIR)
@ -114,20 +114,15 @@ func deploy
-h, --help help for deploy
-i, --image string Full image name in the form [registry]/[namespace]/[name]:[tag]@[digest]. This option takes precedence over --registry. Specifying digest is optional, but if it is given, 'build' and 'push' phases are disabled. (Env: $FUNC_IMAGE)
-n, --namespace string Deploy into a specific namespace. Will use function's current namespace by default if already deployed, and the currently active namespace if it can be determined. (Env: $FUNC_NAMESPACE)
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
--platform string Optionally specify a specific platform to build for (e.g. linux/amd64). (Env: $FUNC_PLATFORM)
-u, --push Push the function image to registry before deploying. (Env: $FUNC_PUSH) (default true)
-r, --registry string Container registry + registry namespace. (ex 'ghcr.io/myuser'). The full image name is automatically determined using this along with function name. (Env: $FUNC_REGISTRY)
--remote Trigger a remote deployment. Default is to deploy and build from the local system (Env: $FUNC_REMOTE)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -1,10 +1,10 @@
## func describe
Describe a Function
Describe a function
### Synopsis
Describe a Function
Describe a function
Prints the name, route and event subscriptions for a deployed function in
the current directory or from the directory specified with --path.
@ -32,16 +32,11 @@ func describe --output yaml --path myotherfunc
-h, --help help for describe
-n, --namespace string The namespace in which to look for the named function. (Env: $FUNC_NAMESPACE)
-o, --output string Output format (human|plain|json|xml|yaml|url) (Env: $FUNC_OUTPUT) (default "human")
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -1,6 +1,6 @@
## func invoke
Invoke a function
Invoke a local or remote function
### Synopsis
@ -94,7 +94,7 @@ func invoke
### Options
```
-c, --confirm Prompt to confirm all options interactively. (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
--content-type string Content Type of the data. (Env: $FUNC_CONTENT_TYPE) (default "application/json")
--data string Data to send in the request. (Env: $FUNC_DATA) (default "{\"message\":\"Hello World\"}")
--file string Path to a file to use as data. Overrides --data flag and should be sent with a correct --content-type. (Env: $FUNC_FILE)
@ -102,19 +102,14 @@ func invoke
-h, --help help for invoke
--id string ID for the request data. (Env: $FUNC_ID)
-i, --insecure Allow insecure server connections when using SSL. (Env: $FUNC_INSECURE)
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
--source string Source value for the request data. (Env: $FUNC_SOURCE) (default "/boson/fn")
-t, --target string Function instance to invoke. Can be 'local', 'remote' or a URL. Defaults to auto-discovery if not provided. (Env: $FUNC_TARGET)
--type string Type value for the request data. (Env: $FUNC_TYPE) (default "boson.fn")
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -48,15 +48,10 @@ func languages
-h, --help help for languages
--json Set output to JSON format. (Env: $FUNC_JSON)
-r, --repository string URI to a specific repository to consider (Env: $FUNC_REPOSITORY)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -1,10 +1,10 @@
## func list
List functions
List deployed functions
### Synopsis
List functions
List deployed functions
Lists all deployed functions in a given namespace.
@ -35,15 +35,10 @@ func list --all-namespaces --output json
-h, --help help for list
-n, --namespace string The namespace for which to list functions. (Env: $FUNC_NAMESPACE) (default "default")
-o, --output string Output format (human|plain|json|xml|yaml) (Env: $FUNC_OUTPUT) (default "human")
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -136,19 +136,14 @@ func repository
### Options
```
-c, --confirm Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for repository
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions
* [func repository add](func_repository_add.md) - Add a repository
* [func repository list](func_repository_list.md) - List repositories
* [func repository remove](func_repository_remove.md) - Remove a repository

View File

@ -9,13 +9,8 @@ func repository add <name> <url>
### Options
```
-c, --confirm Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for add
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```

View File

@ -9,12 +9,8 @@ func repository list
### Options
```
-h, --help help for list
```
### Options inherited from parent commands
```
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for list
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```

View File

@ -9,13 +9,8 @@ func repository remove <name>
### Options
```
-c, --confirm Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for remove
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```

View File

@ -9,13 +9,8 @@ func repository rename <old> <new>
### Options
```
-c, --confirm Prompt to confirm all options interactively (Env: $FUNC_CONFIRM)
-c, --confirm Prompt to confirm options interactively (Env: $FUNC_CONFIRM)
-h, --help help for rename
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```

View File

@ -45,17 +45,12 @@ func run --build=false
-b, --build string[="true"] Build the function. [auto|true|false]. (default "auto")
-e, --env stringArray Environment variable to set in the form NAME=VALUE. You may provide this flag multiple times for setting multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
-h, --help help for run
-p, --path string Path to the project directory. Default is current working directory (Env: $FUNC_PATH)
-p, --path string Path to the function. Default is current directory (Env: $FUNC_PATH)
-r, --registry string Registry + namespace part of the image if building, ex 'quay.io/myuser' (Env: $FUNC_REGISTRY)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -1,12 +1,12 @@
## func templates
Templates
List available function source templates
### Synopsis
NAME
func templates - list available templates
func templates - list available function source templates
SYNOPSIS
func templates [language] [--json] [-r|--repository]
@ -49,15 +49,10 @@ func templates
-h, --help help for templates
--json Set output to JSON format. (Env: $FUNC_JSON)
-r, --repository string URI to a specific repository to consider (Env: $FUNC_REPOSITORY)
```
### Options inherited from parent commands
```
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions

View File

@ -1,6 +1,6 @@
## func version
Show the version
Function client version information
### Synopsis
@ -30,16 +30,11 @@ func version
### Options
```
-h, --help help for version
```
### Options inherited from parent commands
```
-h, --help help for version
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
```
### SEE ALSO
* [func](func.md) - Serverless functions
* [func](func.md) - func manages Knative Functions