diff --git a/src/command/mod.rs b/src/command/mod.rs index ebc774c..7426a67 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -16,6 +16,7 @@ pub fn is_command( | "vars" | "consts" | "constants" | "del" | "delete" + | "flags" => true, _ => false } @@ -81,6 +82,27 @@ pub fn do_command( return t; }, + "flags" => { + return FormattedText::new( + concat!( + "\n", + "A list of command-line arguments is below\n", + "\n", + "╞════ [t]Flag[n] ════╪════════════════ [t]Function[n] ════════════════╡\n", + " [c]--help[n] Show help\n", + " [c]--version[n] Show version\n", + " [c]--info[n] Show system information\n", + " [c]--256color[n] Use full color support (default)\n", + " [c]--8color[n] Use reduced colors (ANSI, no styling)\n", + " [c]--nocolor[n] Do not use colors\n", + " [c]--nosub[n] Disable inline substitution\n", + " [c]--nosuper[n] Disable superscript powers\n", + " [c]--nooneover[n] Disable \"one-over\" fractions as -1 power\n", + "\n\n" + ).to_string() + ); + }, + "clear" => { return FormattedText::new("[clear]".to_string()); }, diff --git a/src/main.rs b/src/main.rs index 0ec0960..24747aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,9 @@ pub fn main() -> Result<(), std::io::Error> { let mut pb: PromptBuffer = PromptBuffer::new(64); let mut context = Context::new(); - // Set color compatibilty + // Detect color compatibilty + // Currently unused, this is slow. + /* let term_colors = stdout.available_colors().unwrap_or(0); if term_colors >= 256 { context.config.term_color_type = 2; @@ -38,9 +40,7 @@ pub fn main() -> Result<(), std::io::Error> { } else { context.config.term_color_type = 0; } - - context.config.check(); - + */ // Handle command-line arguments @@ -48,6 +48,8 @@ pub fn main() -> Result<(), std::io::Error> { if args.iter().any(|s| s == "--help") { let t = command::do_command(&mut context, &String::from("help")); t.write(&context, &mut stdout)?; + let t = command::do_command(&mut context, &String::from("flags")); + t.write(&context, &mut stdout)?; return Ok(()); } else if args.iter().any(|s| s == "--version") { let t = FormattedText::new(format!( @@ -62,12 +64,27 @@ pub fn main() -> Result<(), std::io::Error> { "Your terminal supports {} colors.\n" ), env!("CARGO_PKG_VERSION"), - term_colors + stdout.available_colors().unwrap_or(0) )); t.write(&context, &mut stdout)?; return Ok(()); + } else if args.iter().any(|s| s == "--256color") { + context.config.term_color_type = 2; + } else if args.iter().any(|s| s == "--8color") { + context.config.term_color_type = 1; + } else if args.iter().any(|s| s == "--0color") { + context.config.term_color_type = 0; + } else if args.iter().any(|s| s == "--nosub") { + context.config.enable_substituion = false; + } else if args.iter().any(|s| s == "--nosuper") { + context.config.enable_super_powers = false; + } else if args.iter().any(|s| s == "--nooneover") { + context.config.enable_one_over_power = false; } + context.config.check(); + + 'outer: loop { pb.write_prompt(&mut context, &mut stdout)?;