diff --git a/cmd/invoke.go b/cmd/invoke.go index 775ad10e68..d2a05fb0ff 100644 --- a/cmd/invoke.go +++ b/cmd/invoke.go @@ -119,7 +119,7 @@ EXAMPLES } // Flags - cmd.Flags().StringP("format", "f", "", "Format of message to send, 'http' or 'cloudevent'. Default is to choose automatically. ($FUNC_FORMAT)") + cmd.Flags().StringP("format", "f", "", "Format of message to send, 'http' or 'cloudevent(s)'. Default is to choose automatically. ($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. ($FUNC_TARGET)") cmd.Flags().StringP("id", "", "", "ID for the request data. ($FUNC_ID)") cmd.Flags().StringP("source", "", fn.DefaultInvokeSource, "Source value for the request data. ($FUNC_SOURCE)") @@ -259,6 +259,11 @@ func newInvokeConfig() (cfg invokeConfig, err error) { cfg.Data = b } + switch strings.ToLower(cfg.Format) { + case "cloudevent", "cloudevents": + cfg.Format = "cloudevent" + } + // if not in confirm/prompting mode, the cfg structure is complete. if !cfg.Confirm { return diff --git a/docs/reference/func_invoke.md b/docs/reference/func_invoke.md index a904be2cbf..0ecaeb3529 100644 --- a/docs/reference/func_invoke.md +++ b/docs/reference/func_invoke.md @@ -100,7 +100,7 @@ func invoke --content-type string Content Type of the data. ($FUNC_CONTENT_TYPE) (default "application/json") --data string Data to send in the request. ($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. ($FUNC_FILE) - -f, --format string Format of message to send, 'http' or 'cloudevent'. Default is to choose automatically. ($FUNC_FORMAT) + -f, --format string Format of message to send, 'http' or 'cloudevent(s)'. Default is to choose automatically. ($FUNC_FORMAT) -h, --help help for invoke --id string ID for the request data. ($FUNC_ID) -i, --insecure Allow insecure server connections when using SSL. ($FUNC_INSECURE)