mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-01-10 16:08:16 -05:00
fix: add tools-file flag and deprecate tools_file (#384)
Add `tools-file` flag and deprecate `tools_file` flag. This is not a
breaking change. The old `tools_file` flag is still usable.
User will see the following message when using `tools_file` flag:
```
Flag --tools_file has been deprecated, please use --tools-file instead
2025-04-03T10:09:12.803165-07:00 INFO "Initialized 2 sources."
```
Help command will reveal the new flag:
```
...
--telemetry-service-name string Sets the value of the service.name resource attribute for telemetry data. (default "toolbox")
--tools-file string File path specifying the tool configuration. (default "tools.yaml")
-v, --version version for toolbox
...
```
Fixes #383
This commit is contained in:
@@ -106,6 +106,9 @@ func NewCommand(opts ...Option) *Command {
|
||||
flags.IntVarP(&cmd.cfg.Port, "port", "p", 5000, "Port the server will listen on.")
|
||||
|
||||
flags.StringVar(&cmd.tools_file, "tools_file", "tools.yaml", "File path specifying the tool configuration.")
|
||||
// deprecate tools_file
|
||||
_ = flags.MarkDeprecated("tools_file", "please use --tools-file instead")
|
||||
flags.StringVar(&cmd.tools_file, "tools-file", "tools.yaml", "File path specifying the tool configuration.")
|
||||
flags.Var(&cmd.cfg.LogLevel, "log-level", "Specify the minimum level logged. Allowed: 'DEBUG', 'INFO', 'WARN', 'ERROR'.")
|
||||
flags.Var(&cmd.cfg.LoggingFormat, "logging-format", "Specify logging format to use. Allowed: 'standard' or 'JSON'.")
|
||||
flags.BoolVar(&cmd.cfg.TelemetryGCP, "telemetry-gcp", false, "Enable exporting directly to Google Cloud Monitoring.")
|
||||
|
||||
@@ -189,14 +189,19 @@ func TestToolFileFlag(t *testing.T) {
|
||||
},
|
||||
{
|
||||
desc: "foo file",
|
||||
args: []string{"--tools_file", "foo.yaml"},
|
||||
args: []string{"--tools-file", "foo.yaml"},
|
||||
want: "foo.yaml",
|
||||
},
|
||||
{
|
||||
desc: "address long",
|
||||
args: []string{"--tools_file", "bar.yaml"},
|
||||
args: []string{"--tools-file", "bar.yaml"},
|
||||
want: "bar.yaml",
|
||||
},
|
||||
{
|
||||
desc: "deprecated flag",
|
||||
args: []string{"--tools_file", "foo.yaml"},
|
||||
want: "foo.yaml",
|
||||
},
|
||||
}
|
||||
for _, tc := range tcs {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user