diff --git a/internal/cli/query.go b/internal/cli/query.go index ac4f09d..4cfaee0 100644 --- a/internal/cli/query.go +++ b/internal/cli/query.go @@ -16,6 +16,20 @@ import ( // stalled connection cannot hang the command indefinitely. const queryTimeout = 2 * time.Minute +// queryCmd implements the explicit `sting query` subcommand. It reuses the +// same runQuery and flag set as the root command's direct-invocation style +// (e.g. `sting --author foo`), so both forms work and the README example +// `sting query --author ...` is satisfied. +var queryCmd = &cobra.Command{ + Use: "query", + Short: "Query a GitHub or GitLab user's commits over a time window", + Long: "Prints a Markdown or JSON commit report.\n\n" + + "This is the primary CLI surface for ad-hoc queries; the identical " + + "engine powers the MCP get_commits tool. All query flags are also " + + "accepted directly on the root command for brevity.", + RunE: runQuery, +} + // registerQueryFlags attaches the per-query flags to cmd. They are local flags // (not bound to viper) because they are request inputs that override the // resolved config defaults for a single invocation. diff --git a/internal/cli/root.go b/internal/cli/root.go index 79f874d..3394160 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -31,7 +31,8 @@ var rootCmd = &cobra.Command{ Use: "sting", Short: "Query a GitHub or GitLab user's commits over a time window", Long: "sting reports a GitHub or GitLab user's commits over a time window for an LLM agent or a terminal.\n\n" + - "Run with query flags to print a report, `sting mcp` to serve the read-only get_commits tool over stdio, " + + "Run `sting query` (or supply query flags directly) to print a report, " + + "`sting mcp` to serve the read-only get_commits tool over stdio, " + "or `sting install` to register that server with your agent runtimes.", SilenceUsage: true, SilenceErrors: true, @@ -60,8 +61,11 @@ func init() { must(v.BindPFlag("max_commits", pf.Lookup("max-commits"))) registerQueryFlags(rootCmd) + // Also register on the query subcommand so `sting query --author ...` works + // with the exact same flag surface (and satisfies documented usage). + registerQueryFlags(queryCmd) - rootCmd.AddCommand(mcpCmd, installCmd, uninstallCmd, versionCmd, authCmd, initCmd) + rootCmd.AddCommand(queryCmd, mcpCmd, installCmd, uninstallCmd, versionCmd, authCmd, initCmd) } // initConfig seeds defaults, wires environment overrides, and reads the config