Skip to content

Latest commit

 

History

History
108 lines (76 loc) · 2.4 KB

File metadata and controls

108 lines (76 loc) · 2.4 KB

Contributing to f

PRs welcome! 🎉

Adding a New Build System

Adding support for a new build system is easy. Just 3 steps:

1. Create a new runner file

Create src/runners/your_runner.rs:

use crate::runner::{Command, Runner};
use std::path::Path;

pub struct YourRunner;

impl Runner for YourRunner {
    fn name(&self) -> &'static str {
        "your-tool"  // e.g., "maven", "gradle", "cmake"
    }

    fn detect_files(&self) -> &'static [&'static str] {
        &["your-config-file"]  // e.g., &["pom.xml"], &["CMakeLists.txt"]
    }

    fn commands(&self, project_path: &Path) -> Vec<Command> {
        vec![
            Command::new("build", "your-cmd").with_args(vec!["build".into()]),
            Command::new("test", "your-cmd").with_args(vec!["test".into()]),
            // Add more commands...
        ]
    }
}

2. Register your runner

Add to src/runners/mod.rs:

mod your_runner;
pub use your_runner::YourRunner;

pub fn all_runners() -> Vec<Box<dyn Runner>> {
    vec![
        // ... existing runners
        Box::new(YourRunner),
    ]
}

3. Update documentation

Add your build system to README.md table:

| `your-config-file` | your-tool | build, test, ... |

That's it!

Runner Trait Reference

pub trait Runner: Send + Sync {
    /// Unique identifier (e.g., "cargo", "npm")
    fn name(&self) -> &'static str;

    /// Files that indicate this project type
    fn detect_files(&self) -> &'static [&'static str];

    /// Available commands for the project
    fn commands(&self, project_path: &Path) -> Vec<Command>;

    /// Execute a command (default impl usually works)
    fn execute(&self, command: &Command, project_path: &Path) -> io::Result<ExitStatus>;
}

Command Helper

// Simple command
Command::new("build", "make").with_args(vec!["build".into()])

// With description (shown in UI)
Command::new("dev", "npm")
    .with_args(vec!["run".into(), "dev".into()])
    .with_description("Start development server")

Tips

  • Dynamic commands: See npm.rs for parsing config files (package.json scripts)
  • Target extraction: See make.rs for parsing Makefile targets
  • Custom executables: See make.rs for reading custom commands from ~/.frc

Code Style

  • Run cargo fmt before committing
  • Run cargo clippy and fix warnings
  • Keep it simple and minimal

Questions?

Open an issue! We're happy to help.