extern crate moins; extern crate termion; use io::Result; use std::env; use std::fs::File; use std::io; use std::io::prelude::*; use moins::Color; use moins::Moins; use moins::PagerOptions; use std::collections::HashMap; // open your cargo lock with the following command : // `cargo run --example cli Cargo.lock` and enjoy the colors ! fn main() -> Result<()> { let args: Vec = env::args().collect(); let path = if args.len() > 1 { Some(args[1].as_str()) } else { None }; let mut content = String::new(); let mut file = if let Some(path) = path { File::open(path)? } else { panic!("expected an input file") }; file.read_to_string(&mut content)?; let mut colors = HashMap::new(); colors.insert("[[package]]", Color::Blue); colors.insert("dependencies", Color::Magenta); colors.insert("version", Color::LightRed); colors.insert("name", Color::Cyan); colors.insert("metadata", Color::Green); let options = PagerOptions { colors, search: false, line_number: false, }; Moins::run(&mut content, Some(options)); Ok(()) }