Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/internal/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func PersistentFlags(parentCmd *cobra.Command, opts *ToolboxOptions) {

// ConfigFileFlags defines flags related to the configuration file.
// It should be applied to any command that requires configuration loading.
func ConfigFileFlags(flags *pflag.FlagSet, opts *ToolboxOptions) {
func ConfigFileFlags(parentCmd *cobra.Command, flags *pflag.FlagSet, opts *ToolboxOptions) {
flags.StringVar(&opts.Config, "config", "", "File path specifying the tool configuration. Cannot be used with --configs, or --config-folder.")
flags.StringVar(&opts.Config, "tools-file", "", "File path specifying the tool configuration. Cannot be used with --tools-files, or --tools-folder.")
_ = flags.MarkDeprecated("tools-file", "please use --config instead") // DEPRECATED
Expand All @@ -52,6 +52,7 @@ func ConfigFileFlags(flags *pflag.FlagSet, opts *ToolboxOptions) {
flags.StringVar(&opts.ConfigFolder, "config-folder", "", "Directory path containing YAML tool configuration files. All .yaml and .yml files in the directory will be loaded and merged. Cannot be used with --config, or --configs.")
flags.StringVar(&opts.ConfigFolder, "tools-folder", "", "Directory path containing YAML tool configuration files. All .yaml and .yml files in the directory will be loaded and merged. Cannot be used with --tools-file, or --tools-files.")
_ = flags.MarkDeprecated("tools-folder", "please use --config-folder instead") // DEPRECATED
parentCmd.MarkFlagsMutuallyExclusive("config", "configs", "config-folder", "tools-file", "tools-files", "tools-folder")
// Fetch prebuilt tools sources to customize the help description
prebuiltHelp := fmt.Sprintf(
"Use a prebuilt tool configuration by source type. Allowed: '%s'. Can be specified multiple times.",
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/invoke/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Example:
},
}
flags := cmd.Flags()
internal.ConfigFileFlags(flags, opts)
internal.ConfigFileFlags(cmd, flags, opts)
return cmd
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/migrate/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewCommand(opts *internal.ToolboxOptions) *cobra.Command {
Long: "Migrate all configuration files provided to the flat format, updating deprecated fields and ensuring compatibility.",
}
flags := cmd.Flags()
internal.ConfigFileFlags(flags, opts)
internal.ConfigFileFlags(cmd.Command, flags, opts)
flags.BoolVar(&cmd.dryRun, "dry-run", false, "Preview the converted format without applying actual changes.")
cmd.RunE = func(*cobra.Command, []string) error { return runMigrate(cmd, opts) }
return cmd.Command
Expand Down
9 changes: 0 additions & 9 deletions cmd/internal/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ func (opts *ToolboxOptions) GetCustomConfigFiles(ctx context.Context) ([]string,

// Load Custom Configurations
if isCustomConfigured {
// Enforce exclusivity among custom flags (tools-file vs tools-files vs tools-folder)
if (opts.Config != "" && len(opts.Configs) > 0) ||
(opts.Config != "" && opts.ConfigFolder != "") ||
(len(opts.Configs) > 0 && opts.ConfigFolder != "") {
errMsg := fmt.Errorf("--config/--tools-file, --configs/--tools-files, and --config-folder/--tools-folder flags cannot be used simultaneously")
logger.ErrorContext(ctx, errMsg.Error())
return nil, isCustomConfigured, errMsg
}

if len(opts.Configs) > 0 {
// Use tools-files
logger.InfoContext(ctx, fmt.Sprintf("retrieving %d tool configuration files", len(opts.Configs)))
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/skills/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewCommand(opts *internal.ToolboxOptions) *cobra.Command {
}

flags := cmd.Flags()
internal.ConfigFileFlags(flags, opts)
internal.ConfigFileFlags(cmd.Command, flags, opts)
flags.StringVar(&cmd.name, "name", "", "Name of the generated skill.")
flags.StringVar(&cmd.description, "description", "", "Description of the generated skill")
flags.StringVar(&cmd.toolset, "toolset", "", "Name of the toolset to convert into a skill. If not provided, all tools will be included.")
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func NewCommand(opts *internal.ToolboxOptions) *cobra.Command {
// setup flags that are common across all commands
internal.PersistentFlags(cmd, opts)
flags := cmd.Flags()
internal.ConfigFileFlags(flags, opts)
internal.ConfigFileFlags(cmd, flags, opts)
internal.ServeFlags(flags, opts)
flags.BoolVar(&opts.Cfg.DisableReload, "disable-reload", false, "Disables dynamic reloading of tools file.")
flags.BoolVar(&opts.Cfg.IgnoreUnknownTools, "ignore-unknown-tools", false, "Log warnings and skip unknown/unsupported tool types instead of failing to start.")
Expand Down
4 changes: 2 additions & 2 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,12 @@ func TestMutuallyExclusiveFlags(t *testing.T) {
{
desc: "--config and --configs",
args: []string{"--config", "my.yaml", "--configs", "a.yaml,b.yaml"},
errString: "--config/--tools-file, --configs/--tools-files, and --config-folder/--tools-folder flags cannot be used simultaneously",
errString: "if any flags in the group [config configs config-folder tools-file tools-files tools-folder] are set none of the others can be; [config configs] were all set",
},
{
desc: "--config-folder and --configs",
args: []string{"--config-folder", "./", "--configs", "a.yaml,b.yaml"},
errString: "--config/--tools-file, --configs/--tools-files, and --config-folder/--tools-folder flags cannot be used simultaneously",
errString: "if any flags in the group [config configs config-folder tools-file tools-files tools-folder] are set none of the others can be; [config-folder configs] were all set",
},
}

Expand Down
Loading