Add bns exec command for arbitrary command execution in containers#73
Merged
alexo-bunnyshell merged 2 commits intomasterfrom Jan 19, 2026
Merged
Add bns exec command for arbitrary command execution in containers#73alexo-bunnyshell merged 2 commits intomasterfrom
alexo-bunnyshell merged 2 commits intomasterfrom
Conversation
Implements a new top-level 'bns exec' utility command that allows running arbitrary commands in component containers, similar to kubectl exec and docker exec. Command Structure: - Component ID as positional argument: bns exec <component-id> - Falls back to context if component ID not provided - Registered as top-level utility command (not under 'bns components') Features: - Execute arbitrary commands in component containers - Interactive or explicit pod/container selection via wizards - TTY and stdin control via --tty and --stdin flags (no shorthands) - Defaults to interactive shell (/bin/sh) when no command specified - Auto-enables --tty and --stdin for interactive shells - Supports namespace/pod-name format for pod specification - Reuses existing K8s exec infrastructure (pkg/k8s/kubectl/exec) Implementation: - New directory: cmd/exec/ - New file: cmd/exec/root.go (245 lines) - Modified: cmd/utils/root.go (registered exec command) - Pattern follows other utility commands (git, port-forward) Usage Examples: - Interactive shell: bns exec comp-123 - Run command: bns exec comp-123 -- ls -la /app - With flags: bns exec comp-123 --tty --stdin --pod my-pod -c api - From context: bns configure set-context --component comp-123; bns exec - Pipe input: bns exec comp-123 --stdin -- python3 < script.py Documentation: - Updated CLAUDE.md with comprehensive exec command documentation - Added "Utility Commands" section with usage examples - Updated workflow examples to use new command syntax - Documented positional argument pattern and flag conflicts - Added design notes about global flag conflicts Design Decisions: - Positional component ID instead of --id flag (cleaner UX) - No shorthand flags to avoid conflict with global -t (timeout) flag - Follows docker/kubectl conventions for TTY and stdin handling - Auto-detection of interactive mode when no command specified Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Move examples from Long to Example field for proper Cobra formatting - Remove manual Flags documentation from Long field - Let Cobra automatically generate the Flags section - Improves help readability by eliminating duplication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a new top-level
bns executility command that allows running arbitrary commands in component containers, similar tokubectl execanddocker exec.Command Structure
bns exec <component-id>instead ofbns exec --id <id>git,port-forward, and other utilitiesKey Features
--ttyand--stdinflags (no shorthands to avoid global-ttimeout flag conflict)/bin/sh) when no command specified--ttyand--stdinfor interactive shellsnamespace/pod-nameformat for pod specificationpkg/k8s/kubectl/exec)Usage Examples
Implementation
cmd/exec/cmd/exec/root.go(245 lines)cmd/utils/root.go(registered exec command)