1
0

Remove GUI from dust binary

This commit is contained in:
Jeff 2023-08-28 14:28:59 -04:00
parent c85d807942
commit 02e62efe15

View File

@ -1,6 +1,5 @@
//! Command line interface for the whale programming language. //! Command line interface for the whale programming language.
use clap::Parser; use clap::Parser;
use eframe::{run_native, NativeOptions};
use nu_ansi_term::{Color, Style}; use nu_ansi_term::{Color, Style};
use reedline::{ use reedline::{
default_emacs_keybindings, ColumnarMenu, Completer, DefaultHinter, DefaultPrompt, default_emacs_keybindings, ColumnarMenu, Completer, DefaultHinter, DefaultPrompt,
@ -13,10 +12,7 @@ use std::{
path::PathBuf, path::PathBuf,
}; };
use dust_lib::{ use dust_lib::{eval, eval_with_context, Tool, ToolInfo, Value, VariableMap, TOOL_LIST};
eval, eval_with_context, tools::gui::GuiApp, Result, Tool, ToolInfo, Value, VariableMap,
TOOL_LIST,
};
/// Command-line arguments to be parsed. /// Command-line arguments to be parsed.
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@ -26,10 +22,6 @@ struct Args {
#[arg(short, long)] #[arg(short, long)]
command: Option<String>, command: Option<String>,
// Whether to launch the dedicated GUI window.
#[arg(short, long)]
gui: bool,
/// Location of the file to run. /// Location of the file to run.
path: Option<String>, path: Option<String>,
} }
@ -37,7 +29,7 @@ struct Args {
fn main() { fn main() {
let args = Args::parse(); let args = Args::parse();
if !args.gui && args.path.is_none() && args.command.is_none() { if args.path.is_none() && args.command.is_none() {
return run_cli_shell(); return run_cli_shell();
} }
@ -51,25 +43,12 @@ fn main() {
Ok(Value::Empty) Ok(Value::Empty)
}; };
if args.gui {
return run_gui_shell(eval_result);
}
match eval_result { match eval_result {
Ok(value) => println!("{value}"), Ok(value) => println!("{value}"),
Err(error) => eprintln!("{error}"), Err(error) => eprintln!("{error}"),
} }
} }
fn run_gui_shell(result: Result<Value>) {
run_native(
&Value::Empty.to_string(),
NativeOptions::default(),
Box::new(|_cc| Box::new(GuiApp::new(result))),
)
.unwrap();
}
fn run_cli_shell() { fn run_cli_shell() {
let mut context = VariableMap::new(); let mut context = VariableMap::new();
let mut line_editor = setup_reedline(); let mut line_editor = setup_reedline();