polish: Trim whitespace in --deps flag parsing
Handle edge cases in dependency spec parsing: - Skip empty dependency specs (e.g., from trailing commas) - Trim whitespace around type and ID (e.g., 'discovered-from: bd-20') This makes the flag more forgiving of user input errors.
This commit is contained in:
@@ -588,6 +588,12 @@ var createCmd = &cobra.Command{
|
|||||||
|
|
||||||
// Add dependencies if specified (format: type:id or just id for default "blocks" type)
|
// Add dependencies if specified (format: type:id or just id for default "blocks" type)
|
||||||
for _, depSpec := range deps {
|
for _, depSpec := range deps {
|
||||||
|
// Skip empty specs (e.g., from trailing commas)
|
||||||
|
depSpec = strings.TrimSpace(depSpec)
|
||||||
|
if depSpec == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
var depType types.DependencyType
|
var depType types.DependencyType
|
||||||
var dependsOnID string
|
var dependsOnID string
|
||||||
|
|
||||||
@@ -598,8 +604,8 @@ var createCmd = &cobra.Command{
|
|||||||
fmt.Fprintf(os.Stderr, "Warning: invalid dependency format '%s', expected 'type:id' or 'id'\n", depSpec)
|
fmt.Fprintf(os.Stderr, "Warning: invalid dependency format '%s', expected 'type:id' or 'id'\n", depSpec)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
depType = types.DependencyType(parts[0])
|
depType = types.DependencyType(strings.TrimSpace(parts[0]))
|
||||||
dependsOnID = parts[1]
|
dependsOnID = strings.TrimSpace(parts[1])
|
||||||
} else {
|
} else {
|
||||||
// Default to "blocks" if no type specified
|
// Default to "blocks" if no type specified
|
||||||
depType = types.DepBlocks
|
depType = types.DepBlocks
|
||||||
|
|||||||
Reference in New Issue
Block a user