fix(hyperguild): remove redundant subcommand prefixes from error messages
dispatch() already prefixes errors with 'hyperguild <subcmd>: ', so handlers re-prefixing with their own name produced stuttered output like 'hyperguild brain: brain query: topic required'. Strip the redundant prefixes from the seven affected errors.New / fmt.Errorf calls in brain.go and mode.go. Also fix the LITELLM_BASE_URL usage text — it's optional (empty falls through to airplane tier), not required, matching the README.
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func runBrain(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error {
|
func runBrain(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
return errors.New("brain: subcommand required (query|write)")
|
return errors.New("subcommand required (query|write)")
|
||||||
}
|
}
|
||||||
switch args[0] {
|
switch args[0] {
|
||||||
case "query":
|
case "query":
|
||||||
@@ -19,7 +19,7 @@ func runBrain(ctx context.Context, args []string, stdin io.Reader, stdout, stder
|
|||||||
case "write":
|
case "write":
|
||||||
return runBrainWrite(ctx, args[1:], stdin, stdout, stderr)
|
return runBrainWrite(ctx, args[1:], stdin, stdout, stderr)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("brain: unknown subcommand: %s (expected query|write)", args[0])
|
return fmt.Errorf("unknown subcommand: %s (expected query|write)", args[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ func runBrainQuery(ctx context.Context, args []string, _ io.Reader, stdout, stde
|
|||||||
return fmt.Errorf("parse flags: %w", err)
|
return fmt.Errorf("parse flags: %w", err)
|
||||||
}
|
}
|
||||||
if fs.NArg() < 1 {
|
if fs.NArg() < 1 {
|
||||||
return errors.New("brain query: topic required")
|
return errors.New("topic required")
|
||||||
}
|
}
|
||||||
topic := fs.Arg(0)
|
topic := fs.Arg(0)
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ func runBrainWrite(ctx context.Context, args []string, stdin io.Reader, stdout,
|
|||||||
return fmt.Errorf("parse flags: %w", err)
|
return fmt.Errorf("parse flags: %w", err)
|
||||||
}
|
}
|
||||||
if fs.NArg() < 2 {
|
if fs.NArg() < 2 {
|
||||||
return errors.New("brain write: type and slug required (e.g. brain write knowledge my-slug)")
|
return errors.New("type and slug required (e.g. brain write knowledge my-slug)")
|
||||||
}
|
}
|
||||||
kind := fs.Arg(0)
|
kind := fs.Arg(0)
|
||||||
slug := fs.Arg(1)
|
slug := fs.Arg(1)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ Environment:
|
|||||||
ANTHROPIC_PROBE_URL Tier probe URL for the Anthropic API.
|
ANTHROPIC_PROBE_URL Tier probe URL for the Anthropic API.
|
||||||
Default: https://api.anthropic.com
|
Default: https://api.anthropic.com
|
||||||
LITELLM_BASE_URL Tier probe URL for the LiteLLM gateway.
|
LITELLM_BASE_URL Tier probe URL for the LiteLLM gateway.
|
||||||
Required for tier probe; no default.
|
Optional; if empty, falls through to airplane tier.
|
||||||
`
|
`
|
||||||
|
|
||||||
// dispatch routes args to a subcommand and returns the process exit code.
|
// dispatch routes args to a subcommand and returns the process exit code.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func runMode(ctx context.Context, args []string, _ io.Reader, stdout, stderr io.
|
|||||||
// Pull the first positional (mode name) out so flags after it still parse
|
// Pull the first positional (mode name) out so flags after it still parse
|
||||||
// with stdlib flag (which stops at the first non-flag arg).
|
// with stdlib flag (which stops at the first non-flag arg).
|
||||||
if len(args) < 1 {
|
if len(args) < 1 {
|
||||||
return errors.New("mode: name required (cloud|client-local|sovereign)")
|
return errors.New("name required (cloud|client-local|sovereign)")
|
||||||
}
|
}
|
||||||
name := args[0]
|
name := args[0]
|
||||||
if err := fs.Parse(args[1:]); err != nil {
|
if err := fs.Parse(args[1:]); err != nil {
|
||||||
@@ -39,12 +39,12 @@ func runMode(ctx context.Context, args []string, _ io.Reader, stdout, stderr io.
|
|||||||
case "sovereign":
|
case "sovereign":
|
||||||
doc = modeSovereign(brainURL)
|
doc = modeSovereign(brainURL)
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("mode: unknown mode: %s (expected cloud|client-local|sovereign)", name)
|
return fmt.Errorf("unknown mode: %s (expected cloud|client-local|sovereign)", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*force {
|
if !*force {
|
||||||
if _, err := os.Stat(*out); err == nil {
|
if _, err := os.Stat(*out); err == nil {
|
||||||
return fmt.Errorf("mode: %s exists (use --force to overwrite)", *out)
|
return fmt.Errorf("%s exists (use --force to overwrite)", *out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user