@@ -13,8 +13,6 @@ import (
1313 "slices"
1414 "strings"
1515
16- "github.com/urfave/cli/v3"
17-
1816 "github.com/sourcegraph/sourcegraph/lib/errors"
1917
2018 "github.com/sourcegraph/src-cli/internal/api"
@@ -66,6 +64,7 @@ The commands are:
6664 search search for results on Sourcegraph
6765 search-jobs manages search jobs
6866 serve-git serves your local git repositories over HTTP for Sourcegraph to pull
67+ tool exposes tools for AI agents to interact with Sourcegraph
6968 users,user manages users
7069 codeowners manages code ownership information
7170 version display and compare the src-cli version against the recommended version for your instance
@@ -88,56 +87,19 @@ var (
8887// commands contains all registered subcommands.
8988var commands commander
9089
91- var mainCmd = & cli.Command {
92- Name : "src" ,
93- Aliases : []string {},
94- Usage : "Sourcegraph CLI tool" ,
95- ArgsUsage : "command [options]" ,
96- Version : "dev" ,
97- Description : `src is a tool that provides access to Sourcegraph instances.
98- For more information, see https://github.com/sourcegraph/src-cli` ,
99- DefaultCommand : "old" ,
100- Category : "" ,
101- Commands : []* cli.Command {
102- oldSrcCmd ,
103- },
104- Flags : []cli.Flag {},
105- InvalidFlagAccessHandler : nil ,
106- Hidden : false ,
107- Authors : []any {},
108- Copyright : "Sourcegraph, Inc." ,
109- HideVersion : false ,
110- }
111-
112- // oldSrcCmd is a temporary command that just runs the old cli.
113- //
114- // Any top level flags like --help / -v will be capture by urfave parser
115- var oldSrcCmd = & cli.Command {
116- Name : "old" ,
117- Description : "run the old src command line parser" ,
118- Hidden : true ,
119- HideHelp : true ,
120- Action : func (ctx context.Context , c * cli.Command ) error {
121- oldRun ()
122- return nil
123- },
124- }
125-
12690func main () {
12791 // Configure logging.
12892 log .SetFlags (0 )
12993 log .SetPrefix ("" )
13094
131- if os .Getenv ("SRC_INTERNAL_CLIFLAGS_V2" ) == "1" {
132- if err := mainCmd .Run (context .Background (), os .Args ); err != nil {
95+ // Handle "tool" subcommand specially - it uses urfave/cli/v3
96+ if len (os .Args ) >= 2 && os .Args [1 ] == "tool" {
97+ if err := toolCmd .Run (context .Background (), os .Args [1 :]); err != nil {
13398 log .Fatal (err )
13499 }
135- } else {
136- oldRun ()
100+ return
137101 }
138- }
139102
140- func oldRun () {
141103 commands .run (flag .CommandLine , "src" , usageText , normalizeDashHelp (os .Args [1 :]))
142104}
143105
@@ -369,4 +331,4 @@ func expandHomeDir(filePath string) (string, error) {
369331 }
370332
371333 return filePath , nil
372- }
334+ }
0 commit comments