Add friendlier output where possible
This commit is contained in:
		
							
								
								
									
										7
									
								
								src/conlang.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/conlang.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| #[cfg(feature = "conlang")] | ||||
| const CONLANG_SUPPLEMENTAL: &str = include_str!("conlang-supplemental.pest"); | ||||
|  | ||||
| pub fn print_supplemental() { | ||||
|     #[cfg(feature = "conlang")] | ||||
|     println!("\n// CONLANG_SUPPLEMENTAL\n{CONLANG_SUPPLEMENTAL}"); | ||||
| } | ||||
							
								
								
									
										16
									
								
								src/datetime.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/datetime.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| #[cfg(feature = "datetime")] | ||||
| use datetime::{LocalDateTime, ISO}; | ||||
|  | ||||
| #[cfg(feature = "datetime")] | ||||
| struct Now(LocalDateTime); | ||||
| #[cfg(feature = "datetime")] | ||||
| impl std::fmt::Display for Now { | ||||
|     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||||
|         self.0.fmt(f) | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub fn print_current_time() { | ||||
|     #[cfg(feature = "datetime")] | ||||
|     println!("// Generated {}", Now(LocalDateTime::now())) | ||||
| } | ||||
							
								
								
									
										22
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -1,19 +1,25 @@ | ||||
| use grammatical::*; | ||||
| use std::error::Error; | ||||
|  | ||||
| use grammatical::*; | ||||
| mod conlang; | ||||
| mod datetime; | ||||
|  | ||||
| fn main() -> Result<(), Box<dyn Error>> { | ||||
|     for file in std::env::args().skip(1) { | ||||
|     datetime::print_current_time(); | ||||
|     let args: Vec<_> = std::env::args().skip(1).collect(); | ||||
|     if args.is_empty() { | ||||
|         for line in std::io::stdin().lines() { | ||||
|             let line = line?; | ||||
|             let mut p = Parser::new(&line); | ||||
|             parse(&mut p); | ||||
|         } | ||||
|     } | ||||
|     for file in args { | ||||
|         let file = std::fs::read_to_string(file)?; | ||||
|         let mut p = Parser::new(&file); | ||||
|         parse(&mut p); | ||||
|     } | ||||
|  | ||||
|     for line in std::io::stdin().lines() { | ||||
|         let line = line?; | ||||
|         let mut p = Parser::new(&line); | ||||
|         parse(&mut p); | ||||
|     } | ||||
|     conlang::print_supplemental(); | ||||
|     Ok(()) | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user