Skip to content
Merged
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
1 change: 1 addition & 0 deletions agents/docs/commands-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ help text).
| `fbuild iwyu` | Run `include-what-you-use` analysis. | `fbuild help iwyu` |
| `fbuild clang-query` | Run a clang-query matcher script over the project. | `fbuild help clang-query` |
| `fbuild clangd-config` | Emit `.clangd` / `.vscode/settings.json` for the default env. | `fbuild help clangd-config` |
| `fbuild ide` / `fbuild ide select` | You want to open a project as an IDE workspace on stock Zed: installs declared deps, refreshes the compile DB, emits `.clangd` + `.zed/settings.json` + `.zed/tasks.json`, launches Zed. `ide select` interactively (or via `-e`) switches the persisted environment and regenerates. | `fbuild help ide`, FastLED/fbuild#1076 Phase 1, `docs/reference/cli.md#fbuild-ide` |
| `fbuild lib-select` | Drive the LDF-style library-selection resolver and print the selected library set. Use this when debugging "library not found" without a full build. | FastLED/fbuild#202 / #204 |

## Daemon & cache
Expand Down
35 changes: 35 additions & 0 deletions crates/fbuild-cli/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,20 @@ pub enum Commands {
#[arg(long)]
refresh: bool,
},
/// Open (or configure) this project as an IDE workspace on stock Zed:
/// installs declared deps, refreshes the clangd compile database, emits
/// `.clangd` / `.zed/settings.json` / `.zed/tasks.json`, then launches
/// Zed (FastLED/fbuild#1076 Phase 1)
Ide {
project_dir: Option<String>,
#[arg(short = 'e', long)]
environment: Option<String>,
/// Generate/refresh IDE config but don't launch the Zed process.
#[arg(long)]
no_launch: bool,
#[command(subcommand)]
action: Option<IdeAction>,
},
/// Build firmware and run it in an emulator for testing
TestEmu {
project_dir: Option<String>,
Expand Down Expand Up @@ -936,6 +950,26 @@ pub enum BloatCmd {
},
}

/// `fbuild ide <action>` — today only `select` (interactive environment
/// picker). Nested under `Commands::Ide` alongside its own `project_dir` /
/// `environment` / `no_launch` args: when the first token after `ide`
/// doesn't match a known action name, clap falls back to treating it as
/// `Commands::Ide`'s own `project_dir` positional (FastLED/fbuild#1076
/// Phase 1).
#[derive(Subcommand, Debug)]
pub enum IdeAction {
/// Interactively choose (and persist) the PlatformIO environment used
/// for this project's IDE config, then regenerate the compile database
/// and `.clangd` / `.zed/*` files for it.
Select {
project_dir: Option<String>,
/// Non-interactive: pick this environment directly instead of
/// prompting.
#[arg(short = 'e', long)]
environment: Option<String>,
},
}

/// Resolve project_dir: prefer the subcommand's value, fall back to the top-level positional arg,
/// then default to ".". This lets callers write either `fbuild build <dir>` or `fbuild <dir> build`.
pub fn resolve_project_dir(
Expand All @@ -962,6 +996,7 @@ pub const KNOWN_SUBCOMMANDS: &[&str] = &[
"clang-tidy",
"iwyu",
"clangd-config",
"ide",
"clang-query",
"test-emu",
"lib-select",
Expand Down
22 changes: 21 additions & 1 deletion crates/fbuild-cli/src/cli/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::Path;

use crate::{daemon_client, lib_select, mcp, output, update_check};

use super::args::{BloatCmd, Cli, Commands, resolve_project_dir, rewrite_args};
use super::args::{BloatCmd, Cli, Commands, IdeAction, resolve_project_dir, rewrite_args};
use super::bloat_lookup::run_bloat_lookup;
use super::bringup::run_bringup;
use super::build::run_build;
Expand All @@ -21,6 +21,7 @@ use super::daemon_cmd::run_daemon;
use super::deploy::{run_deploy, run_monitor, run_test_emu};
use super::device::run_device;
use super::graph_cmd::run_bloat_graph;
use super::ide::{run_ide, run_ide_select};
use super::lnk::run_lnk;
use super::monitor_parse::parse_monitor_flags;
use super::pio::{pio_build, pio_deploy, pio_monitor};
Expand Down Expand Up @@ -459,6 +460,25 @@ pub async fn async_main() {
let project_dir = resolve_project_dir(project_dir, &top_level_project_dir);
run_clangd_config(project_dir, environment, verbose, editor, refresh).await
}
Some(Commands::Ide {
project_dir,
environment,
no_launch,
action,
}) => match action {
Some(IdeAction::Select {
project_dir: select_project_dir,
environment: select_environment,
}) => {
let project_dir =
resolve_project_dir(select_project_dir.or(project_dir), &top_level_project_dir);
run_ide_select(project_dir, select_environment.or(environment)).await
}
None => {
let project_dir = resolve_project_dir(project_dir, &top_level_project_dir);
run_ide(project_dir, environment, no_launch).await
}
},
Some(Commands::TestEmu {
project_dir,
environment,
Expand Down
Loading
Loading