Skip to content

Commit c4a0331

Browse files
committed
fix: empty name default
1 parent 7125924 commit c4a0331

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

cmd/create.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ EXAMPLES
9090
cmd.Flags().StringP("repository", "r", "", "URI to a Git repository containing the specified template ($FUNC_REPOSITORY)")
9191

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

9798
addVerboseFlag(cmd, cfg.Verbose)
9899

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

184185
pathFlag = viper.GetString("path")
185186

186-
finalPath := "."
187+
// Default to empty string which deriveNameAndAbsolutePathFromPath
188+
// interprets as current working directory
189+
finalPath := ""
190+
191+
// Use --path flag if provided (takes precedence)
187192
if pathFlag != "" && pathFlag != "." {
188193
finalPath = pathFlag
194+
} else if pathFlag == "." {
195+
// Convert shell convention "." to empty string for internal use
196+
finalPath = ""
189197
} else if len(args) >= 1 && args[0] != "" {
190-
finalPath = args[0]
198+
// Fall back to positional argument if no --path flag
199+
if args[0] == "." {
200+
// Convert shell convention "." to empty string
201+
finalPath = ""
202+
} else {
203+
finalPath = args[0]
204+
}
191205
}
192206

193207
dirName, absolutePath = deriveNameAndAbsolutePathFromPath(finalPath)

docs/reference/func_create.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func create
7070
-c, --confirm Prompt to confirm options interactively ($FUNC_CONFIRM)
7171
-h, --help help for create
7272
-l, --language string Language Runtime (see help text for list) ($FUNC_LANGUAGE)
73-
-p, --path string Path to the function project directory ($FUNC_PATH) (default ".")
73+
-p, --path string Path to the function project directory ($FUNC_PATH)
7474
-r, --repository string URI to a Git repository containing the specified template ($FUNC_REPOSITORY)
7575
-t, --template string Function template. (see help text for list) ($FUNC_TEMPLATE) (default "http")
7676
-v, --verbose Print verbose logs ($FUNC_VERBOSE)

0 commit comments

Comments
 (0)