From 190026c4927a97247d68530ec8bfcee24c923737 Mon Sep 17 00:00:00 2001 From: Manuel Odendahl Date: Fri, 24 Jan 2025 00:29:28 -0500 Subject: [PATCH] :sparkles: Properly pass arguments and flags to the final command --- .gitignore | 1 + doc/shell-commands.md | 6 +++--- examples/shell-commands/docker-comp.yaml | 2 +- examples/shell-commands/find-code-files.yaml | 9 +++++---- examples/shell-commands/git-sync.yaml | 2 +- pkg/cmds/shell-tool-provider.go | 3 ++- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index d52c0ac..4c386d1 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ dist/ .env .envrc .history +__debug* diff --git a/doc/shell-commands.md b/doc/shell-commands.md index f2ae22d..97e34b3 100644 --- a/doc/shell-commands.md +++ b/doc/shell-commands.md @@ -31,7 +31,7 @@ long: | Detailed description that can span multiple lines flags: - - name: flag-name + - name: flag_name type: string help: Flag description required: true @@ -162,7 +162,7 @@ flags: default: 2024-01-01 # Choice from predefined options - - name: group-by + - name: group_by type: choice help: Result grouping choices: [year, month, all-time] @@ -297,7 +297,7 @@ A log processing script with multiple options: name: analyze-logs short: Analyze application logs flags: - - name: log-dir + - name: log_dir type: string help: Log directory required: true diff --git a/examples/shell-commands/docker-comp.yaml b/examples/shell-commands/docker-comp.yaml index cc4bc2e..bceff91 100644 --- a/examples/shell-commands/docker-comp.yaml +++ b/examples/shell-commands/docker-comp.yaml @@ -5,7 +5,7 @@ long: | configurable compose file location. flags: - - name: compose-file + - name: compose_file type: string help: Path to docker-compose.yml default: docker-compose.yml diff --git a/examples/shell-commands/find-code-files.yaml b/examples/shell-commands/find-code-files.yaml index a5ec21c..4e5191a 100644 --- a/examples/shell-commands/find-code-files.yaml +++ b/examples/shell-commands/find-code-files.yaml @@ -43,7 +43,7 @@ flags: Use "." for current directory. default: "." - - name: modified-after + - name: modified_after type: string help: | Filter files modified after specified time. @@ -54,7 +54,7 @@ flags: - "24 hours ago" - "2023-12-31" - - name: min-size + - name: min_size type: string help: | Minimum file size filter. @@ -64,7 +64,7 @@ flags: - "1M" (1 megabyte) - "2G" (2 gigabytes) - - name: max-size + - name: max_size type: string help: | Maximum file size filter. @@ -74,7 +74,7 @@ flags: - "1M" (1 megabyte) - "2G" (2 gigabytes) - - name: exclude-dir + - name: exclude_dir type: stringList help: | Directories to exclude from search. @@ -134,4 +134,5 @@ shell-script: | done # Execute find command with extension pattern + echo "$find_cmd \( $ext_pattern \) -type f" eval "$find_cmd \( $ext_pattern \) -type f" \ No newline at end of file diff --git a/examples/shell-commands/git-sync.yaml b/examples/shell-commands/git-sync.yaml index 8ebb911..886b636 100644 --- a/examples/shell-commands/git-sync.yaml +++ b/examples/shell-commands/git-sync.yaml @@ -5,7 +5,7 @@ long: | and optionally pushing local changes. flags: - - name: repos-dir + - name: repos_dir type: string help: Base directory containing git repositories required: true diff --git a/pkg/cmds/shell-tool-provider.go b/pkg/cmds/shell-tool-provider.go index 57f7756..fc4c4a6 100644 --- a/pkg/cmds/shell-tool-provider.go +++ b/pkg/cmds/shell-tool-provider.go @@ -99,8 +99,9 @@ func (p *ShellToolProvider) CallTool(ctx context.Context, name string, arguments // Create a buffer to capture the command output buf := &strings.Builder{} + dataMap := parsedLayers.GetDataMap() // Run the command with parsed parameters - err = tool.cmd.ExecuteCommand(ctx, parsedLayers.GetDataMap(), buf) + err = tool.cmd.ExecuteCommand(ctx, dataMap, buf) if err != nil { return protocol.NewErrorToolResult(protocol.NewTextContent(err.Error())), nil }