Skip to content

[Feature] Allow running commands directly from the CLI #2330

@fmatsos

Description

@fmatsos

This feature request proposes the ability to execute opencode commands directly from the command-line interface (CLI) without needing to enter the Text-based User Interface (TUI).

Problem

Currently, opencode allows running a prompt with a specific agent via the CLI using opencode run --agent myagent prompt. However, there is no equivalent functionality to run a pre-defined command directly. To execute a command, a user must launch the TUI, which can be inefficient for quick tasks or for use in scripts.

Proposed Solution

I propose adding a --command flag to the opencode run subcommand. This would allow users to specify a command to be executed directly from the CLI, along with any necessary arguments.

Examples

Current Behavior (for agents)

opencode run --agent myagent "This is my prompt"

Desired Behavior (for commands)

opencode run --command mycommand "argument1" "argument2"

Benefits

  • Improved Workflow: Allows for a faster and more streamlined workflow for users who want to execute a specific command without the overhead of the TUI.
  • Scripting and Automation: Enables the integration of opencode commands into shell scripts and other automation workflows.
  • Consistency: Aligns the CLI experience of running commands with the existing experience of running agents.

This would make opencode even more powerful and flexible as a CLI tool.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions