package cmd import ( "flag" "strings" "git.noodles.cam/claude-skills/marketplace/cli/internal/issue" "git.noodles.cam/claude-skills/marketplace/cli/internal/project" ) // storeFlag registers the one flag almost every command has. // // An explicit --out overrides the resolved store and is used exactly as typed: // a relative --out stays relative to the working directory, because that is // what the operator asked for. func storeFlag(fs *flag.FlagSet) *string { return fs.String("out", "", "store root (default: /.kettle/issues)") } // storeRoot resolves the store, or explains which directories were searched. // // No marker anywhere is an answer, not a fallback: a store placed in a // plausible-looking directory is the failure the marker exists to replace. func storeRoot(out string) (string, error) { if root := issue.Root(out); root != "" { return root, nil } return "", project.NotFoundError("") } // wasSet reports whether the operator actually typed this flag. // // Needed wherever the empty string is a legitimate value to reject rather than // a synonym for "not given": `--check ""` is an empty selector and an error, // while no --check at all means "just list the boxes". func wasSet(fs *flag.FlagSet, name string) bool { found := false fs.Visit(func(f *flag.Flag) { if f.Name == name { found = true } }) return found } // stringList is a repeatable flag: --label tech/sql --label comp/appclick. type stringList []string func (l *stringList) String() string { return strings.Join(*l, ", ") } func (l *stringList) Set(v string) error { *l = append(*l, v) return nil }