Skip to content

Commit

Permalink
✨ Properly pass arguments and flags to the final command
Browse files Browse the repository at this point in the history
  • Loading branch information
wesen committed Jan 24, 2025
1 parent da406f6 commit 190026c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ dist/
.env
.envrc
.history
__debug*
6 changes: 3 additions & 3 deletions doc/shell-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/shell-commands/docker-comp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions examples/shell-commands/find-code-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -54,7 +54,7 @@ flags:
- "24 hours ago"
- "2023-12-31"
- name: min-size
- name: min_size
type: string
help: |
Minimum file size filter.
Expand All @@ -64,7 +64,7 @@ flags:
- "1M" (1 megabyte)
- "2G" (2 gigabytes)
- name: max-size
- name: max_size
type: string
help: |
Maximum file size filter.
Expand All @@ -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.
Expand Down Expand Up @@ -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"
2 changes: 1 addition & 1 deletion examples/shell-commands/git-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmds/shell-tool-provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 190026c

Please sign in to comment.