Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions crates/forge_main/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@

/// Process JSONL data through LLM with schema-constrained tools.
Data(DataCommandGroup),

/// Install components and extensions.
#[command(subcommand)]
Install(InstallCommand),
}

/// Command group for custom command management.
Expand Down Expand Up @@ -687,6 +691,13 @@
}
}

/// Install commands for components and extensions.
#[derive(Subcommand, Debug, Clone)]
pub enum InstallCommand {
/// Install the Forge VS Code extension.
VscodeExtension,
}

#[cfg(test)]
mod tests {
use clap::Parser;
Expand Down Expand Up @@ -1570,4 +1581,14 @@
};
assert_eq!(actual, true);
}

#[test]
fn test_install_vscode_extension() {
let fixture = Cli::parse_from(["forge", "install", "vscode-extension"]);
let actual = match fixture.subcommands {

Check warning on line 1588 in crates/forge_main/src/cli.rs

View workflow job for this annotation

GitHub Actions / Lint Fix

match expression looks like `matches!` macro
Some(TopLevelCommand::Install(InstallCommand::VscodeExtension)) => true,
_ => false,
};
assert_eq!(actual, true);
}
}
37 changes: 37 additions & 0 deletions crates/forge_main/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,14 @@ impl<A: API + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
self.writeln(data?)?;
}
}
TopLevelCommand::Install(install_command) => {
match install_command {
crate::cli::InstallCommand::VscodeExtension => {
self.on_vscode_extension_install().await?;
}
}
return Ok(());
}
}
Ok(())
}
Expand Down Expand Up @@ -1461,6 +1469,35 @@ impl<A: API + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
Ok(())
}

/// Install the Forge VS Code extension
async fn on_vscode_extension_install(&mut self) -> anyhow::Result<()> {
self.spinner
.start(Some("Installing Forge VS Code extension"))?;

match crate::vscode::install_extension() {
Ok(true) => {
self.spinner.stop(None)?;
self.writeln_title(TitleFormat::info(
"Forge VS Code extension installed successfully",
))?;
}
Ok(false) => {
self.spinner.stop(None)?;
self.writeln_title(TitleFormat::error(
"Failed to install Forge VS Code extension.",
))?;
}
Err(e) => {
self.spinner.stop(None)?;
self.writeln_title(TitleFormat::error(format!(
"Failed to install Forge VS Code extension: {e}"
)))?;
}
}

Ok(())
}

/// Setup ZSH integration by updating .zshrc
async fn on_zsh_setup(&mut self) -> anyhow::Result<()> {
// Check nerd font support
Expand Down
Loading