Accept custom command when launching shell#375
Conversation
WalkthroughThe pull request updates the shell command interface by introducing a new Changes
Sequence Diagram(s)sequenceDiagram
participant User as CLI User
participant Shell as Shell Handler
participant Utils as Launch_Shell
participant Subproc as Popen
User->>Shell: Invoke shell with parameters (including command)
Shell->>Utils: Call launch_shell(command=...)
Utils->>Subproc: Execute Popen with command if provided
Subproc-->>Utils: Return exit code
Utils-->>Shell: Return exit code
Shell-->>User: Relay exit code
Possibly Related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code Definitions (1)packages/jumpstarter-cli/jumpstarter_cli/shell.py (1)
⏰ Context from checks skipped due to timeout of 90000ms (11)
🔇 Additional comments (4)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for jumpstarter-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/jumpstarter/jumpstarter/common/utils.py (2)
83-90: Function signature enhanced with optional command parameterThe updated
launch_shellfunction signature now includes an optional keyword-only parametercommandthat accepts a tuple of strings or None. This allows for both interactive shell usage and execution of specific commands.I notice the
allowparameter type annotation changed fromlist[str]to[str]. This is unusual as[str]is not standard Python type annotation syntax - did you meanlist[str]?-def launch_shell( - host: str, - context: str, - allow: [str], - unsafe: bool, - *, - command: tuple[str, ...] | None, -) -> int: +def launch_shell( + host: str, + context: str, + allow: list[str], + unsafe: bool, + *, + command: tuple[str, ...] | None = None, +) -> int:
98-98: Update function docstring to mention the command parameterThe docstring should be updated to include information about the new
commandparameter.Args: host: The jumpstarter host path context: The context of the shell ("local" or "remote") allow: List of allowed drivers unsafe: Whether to allow drivers outside of the allow list + command: Optional command to execute instead of launching an interactive shell + + Returns: + The exit code of the launched shell processpackages/jumpstarter-cli/jumpstarter_cli/shell.py (1)
24-26: Update docstring to mention the command parameterThe function docstring should be updated to mention the new functionality of executing custom commands.
""" Spawns a shell connecting to a local or remote exporter + + If a command is provided, it will be executed within the shell environment + instead of launching an interactive shell. """
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/jumpstarter-cli/jumpstarter_cli/shell.py(2 hunks)packages/jumpstarter/jumpstarter/common/utils.py(2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/jumpstarter-cli/jumpstarter_cli/shell.py (1)
packages/jumpstarter/jumpstarter/common/utils.py (1)
launch_shell(83-116)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: e2e
- GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-utils Dockerfile.utils)
- GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
- GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
- GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
🔇 Additional comments (6)
packages/jumpstarter/jumpstarter/common/utils.py (2)
99-104: Good refactoring: Environment setup separated from command executionClean refactoring that separates environment setup from command execution logic, making the code more modular and easier to maintain.
106-114: Well-implemented conditional command executionThe implementation correctly handles both cases - executing a specific command or launching the default shell. The code maintains the original behavior for interactive shells while adding support for custom command execution.
packages/jumpstarter-cli/jumpstarter_cli/shell.py (4)
15-15: Command argument added with variadic parameter supportGood implementation using
nargs=-1to allow capturing multiple command arguments. This allows users to pass multiple strings as a single command.
23-23: Type annotation added for command parameterThe function signature has been properly updated to include the new
commandparameter with appropriate type annotation.
35-41: Remote shell launch updated to support custom commandsThe
launch_shellcall for remote shells has been properly updated to include the newcommandparameter.
48-54: Local shell launch updated to support custom commandsThe
launch_shellcall for local shells has been properly updated to include the newcommandparameter.
7438907 to
c8faec0
Compare
c8faec0 to
1bf9013
Compare
Summary by CodeRabbit