Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ EXAMPLES
cmd.Flags().StringP("repository", "r", "", "URI to a Git repository containing the specified template ($FUNC_REPOSITORY)")

addConfirmFlag(cmd, cfg.Confirm)
// Add --path flag (default ".") for consistency with other commands.
// Retain positional [path] for backward compatibility (warned later).
cmd.Flags().StringP("path", "p", ".", "Path to the function project directory ($FUNC_PATH)")
// Add --path flag (default "") for consistency with other commands.
// Retain positional [path] for backward compatibility.
// Empty string default means current directory.
cmd.Flags().StringP("path", "p", "", "Path to the function project directory ($FUNC_PATH)")

addVerboseFlag(cmd, cfg.Verbose)

Expand Down Expand Up @@ -183,11 +184,24 @@ func newCreateConfig(cmd *cobra.Command, args []string, newClient ClientFactory)

pathFlag = viper.GetString("path")

finalPath := "."
// Default to empty string which deriveNameAndAbsolutePathFromPath
// interprets as current working directory
finalPath := ""

// Use --path flag if provided (takes precedence)
if pathFlag != "" && pathFlag != "." {
finalPath = pathFlag
} else if pathFlag == "." {
// Convert shell convention "." to empty string for internal use
finalPath = ""
} else if len(args) >= 1 && args[0] != "" {
finalPath = args[0]
// Fall back to positional argument if no --path flag
if args[0] == "." {
// Convert shell convention "." to empty string
finalPath = ""
} else {
finalPath = args[0]
}
}

dirName, absolutePath = deriveNameAndAbsolutePathFromPath(finalPath)
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/func_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func create
-c, --confirm Prompt to confirm options interactively ($FUNC_CONFIRM)
-h, --help help for create
-l, --language string Language Runtime (see help text for list) ($FUNC_LANGUAGE)
-p, --path string Path to the function project directory ($FUNC_PATH) (default ".")
-p, --path string Path to the function project directory ($FUNC_PATH)
-r, --repository string URI to a Git repository containing the specified template ($FUNC_REPOSITORY)
-t, --template string Function template. (see help text for list) ($FUNC_TEMPLATE) (default "http")
-v, --verbose Print verbose logs ($FUNC_VERBOSE)
Expand Down
Loading