Paramveersingh-S opened a new pull request, #231:
URL: https://github.com/apache/cloudstack-cloudmonkey/pull/231
Fixes #215
### Problem
Operators working inside the interactive `cmk` shell prompt (or scripting
`cmk`) could not run local OS shell commands (e.g., `ls -lR
/etc/cloudstack/extensions/`) directly from the `cmk` prompt as they could in
legacy Python CloudMonkey (`!` / `shell`).
### Solution
1. **`cmd/shell.go`**:
- Registers the built-in `shell` command (`shell <command>`) and
`RunShellCommand(command string)`.
- Uses `$SHELL -c <command>` (falling back to `sh -c`) on Unix-like
systems and `cmd /C <command>` on Windows, wiring `os.Stdin`, `os.Stdout`, and
`os.Stderr` directly.
2. **`cli/exec.go`**:
- Supports both the `!<command>` shorthand (e.g., `!ls -lR
/etc/cloudstack/extensions/` or `! ls -la`) and `shell <command>` in
`ExecLine`, passing the raw command string to the system shell so shell
pipelines, globs, and redirections work naturally.
3. **`cli/exec_test.go`**:
- Adds unit tests verifying `!echo ...`, `shell echo ...`, empty `shell`
error handling, and bare `!` no-op behavior.
### Verification / Solution Proof
```text
$ go test -mod=vendor -v ./cli ./cmd ./config
=== RUN TestFindAutocompleteAPIRelatedNounMatch
--- PASS: TestFindAutocompleteAPIRelatedNounMatch (0.00s)
...
=== RUN TestExecLineBangShellCommand
--- PASS: TestExecLineBangShellCommand (0.04s)
=== RUN TestExecLineShellCommand
--- PASS: TestExecLineShellCommand (0.03s)
=== RUN TestExecLineEmptyShellCommandReturnsError
--- PASS: TestExecLineEmptyShellCommandReturnsError (0.00s)
PASS
ok github.com/apache/cloudstack-cloudmonkey/cli
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]