TUI #1

Merged
shaunrd0 merged 73 commits from ui into master 2026-01-25 20:57:37 +00:00
Showing only changes of commit d53ef9aa1b - Show all commits

View File

@ -2,6 +2,7 @@
use cxx_qt_lib::QString; use cxx_qt_lib::QString;
use std::error::Error; use std::error::Error;
use std::process::{Command, Stdio};
use structopt::StructOpt; use structopt::StructOpt;
pub mod colors; pub mod colors;
@ -34,16 +35,23 @@ fn run_tui(root_path: std::path::PathBuf) -> Result<(), Box<dyn Error>> {
Ok(()) Ok(())
} }
/// Command line interface IDE with full GUI and headless modes.
/// If no flags are provided the GUI editor is launched in a separate process.
/// If no path is provided the current directory is used.
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt(name = "clide")] #[structopt(name = "clide", verbatim_doc_comment)]
struct Cli { struct Cli {
/// The root path to open with the clide editor. /// The root directory for the project to open with the clide editor.
#[structopt(parse(from_os_str))] #[structopt(parse(from_os_str))]
pub path: Option<std::path::PathBuf>, pub path: Option<std::path::PathBuf>,
/// Run in headless mode if this flag is present. /// Run clide in headless mode.
#[structopt(name = "tui", short, long)] #[structopt(name = "tui", short, long)]
pub tui: bool, pub tui: bool,
/// Run the clide GUI in the current process, blocking the terminal and showing all output streams.
#[structopt(name = "gui", short, long)]
pub gui: bool,
} }
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn Error>> {
@ -58,9 +66,23 @@ fn main() -> Result<(), Box<dyn Error>> {
dirs::home_dir().expect("Failed to access filesystem.")), dirs::home_dir().expect("Failed to access filesystem.")),
}; };
match args.gui {
true => run_gui(root_path),
false => {
// Open the TUI editor if requested, otherwise use the QML GUI by default. // Open the TUI editor if requested, otherwise use the QML GUI by default.
match args.tui { match args.tui {
true => run_tui(root_path), true => run_tui(root_path),
false => run_gui(root_path), false => {
// Relaunch the CLIDE GUI in a separate process.
Command::new(std::env::current_exe()?)
.args(&["--gui"])
.stdout(Stdio::null())
.stderr(Stdio::null())
.stdin(Stdio::null())
.spawn()?;
Ok(())
}
}
}
} }
} }