MCPcopy Create free account
hub / github.com/JordanCoin/codemap / parseBlastRadiusArgs

Function parseBlastRadiusArgs

blast_radius.go:295–317  ·  view source on GitHub ↗

parseBlastRadiusArgs parses flags that may appear before or after the single optional positional path. Go's flag package stops at the first non-flag argument, so we re-parse the remainder after each positional to support position-independent flags (e.g. `blast-radius . --json`).

(fs *flag.FlagSet, args []string)

Source from the content-addressed store, hash-verified

293// argument, so we re-parse the remainder after each positional to support
294// position-independent flags (e.g. `blast-radius . --json`).
295func parseBlastRadiusArgs(fs *flag.FlagSet, args []string) (string, error) {
296 var positionals []string
297 rest := args
298 for {
299 if err := fs.Parse(rest); err != nil {
300 return "", err
301 }
302 if fs.NArg() == 0 {
303 break
304 }
305 positionals = append(positionals, fs.Arg(0))
306 rest = fs.Args()[1:]
307 }
308 if len(positionals) > 1 {
309 fmt.Fprintln(os.Stderr, "Usage: codemap blast-radius [--json|--markdown|--text] [--ref <base-ref>] [path]")
310 return "", fmt.Errorf("too many positional arguments")
311 }
312 root := "."
313 if len(positionals) == 1 {
314 root = positionals[0]
315 }
316 return root, nil
317}
318
319// blastRadiusDiffError wraps a git-diff failure so the caller can surface the
320// actionable "valid branch/ref" hint for a bad --ref.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected