-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.
Description
Problem
When running func create with function names starting with a hyphen, the command mis-parses them as flags, resulting in confusing error messages that don't clearly indicate the naming issue.
Current Behavior
Scenario 1: Function name starting with hyphen (template flag conflict)
Command:
func create --language go -test-funcCurrent Output:
Error: The template 'est-func' was not found for language runtime 'go'.
Available templates for this language runtime are:
cloudevents
httpProblems:
- Leading hyphen
-interpreted as flag prefix - CLI parsed
-tfrom-test-funcas the--templateshort flag - Remaining text
est-funcused as template name - Error message doesn't mention the naming issue
- No guidance that function names cannot start with hyphens
Scenario 2: Function name starting with hyphen (language flag conflict)
Command:
func create --language go -language-testCurrent Output:
Error: The language runtime 'anguage-test' is not recognized.
Available language runtimes are:
go
node
python
quarkus
rust
springboot
typescriptProblems:
- CLI parsed
-lfrom-language-testas the--languageshort flag - Remaining text
anguage-testused as runtime name - Error message about invalid runtime instead of invalid name format
- No indication that the argument was mis-parsed
Scenario 3: Function name starting with hyphen (invalid short flag)
Command:
func create --language go -custom-funcCurrent Output:
Error: unknown shorthand flag: 'u' in -ustom-funcProblems:
- CLI parsed
-cfrom-custom-func(no matching short flag exists) - Shows cryptic "unknown shorthand flag: 'u'" error
- User doesn't understand why 'u' is being parsed as a flag
- No guidance on valid naming rules
Scenario 4: Function name starting with double hyphen
Command:
func create --language go --production-funcCurrent Output:
Error: unknown flag: --production-funcProblems:
- Double hyphen
--interpreted as long flag prefix - Generic "unknown flag" error
- No indication this was meant to be a function name
- No guidance on DNS-1035 naming rules
Scenario 5: Function name starting with hyphen and number
Command:
func create --language go -123Current Output:
Error: unknown shorthand flag: '1' in -123Problems:
- Hyphen followed by number parsed as invalid short flag
- Confusing error about flag '1'
- No indication that numbers can't be flags
- No guidance on valid function naming
Proposed Improvement
All scenarios above should display the original error message followed by a helpful note explaining the mis-parsing and DNS-1035 naming rules.
Example (Scenario 1):
Command:
func create --language go -test-funcImproved Output:
Error: The template 'est-func' was not found for language runtime 'go'.
Available templates for this language runtime are:
cloudevents
http
Note: It looks like '-test-func' was interpreted as the flag '-t' with value 'est-func'.
Function names cannot start with hyphens per DNS-1035 naming rules.
Valid function names must start with a letter (a-z) and can contain letters, numbers, and hyphens.Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.