Create basic CLI interface
As of now, it is possible to feed lang-evolve-cli a set of rules as a file, as well as an input as a file too. A `--help` option is provided as well through Clap.
This commit is contained in:
parent
2dec911b1e
commit
fe6efa0b5c
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
||||
/target
|
||||
*.log
|
||||
*.txt
|
||||
*.yaml
|
||||
|
@ -8,3 +8,4 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
lang-evolve-core = { path = "../lang-evolve-core"}
|
||||
clap = "3.0.0-beta.1"
|
||||
|
20
src/main.rs
20
src/main.rs
@ -1,3 +1,21 @@
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
|
||||
use lang_evolve_core::settings::Settings;
|
||||
|
||||
mod opts;
|
||||
use opts::Opts;
|
||||
use clap::Clap;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
lang_evolve_core::init().unwrap();
|
||||
|
||||
let opts: Opts = Opts::parse();
|
||||
let settings = Settings::from(opts.settings).unwrap();
|
||||
let mut input_file = File::open(opts.input).unwrap();
|
||||
let mut input = String::new();
|
||||
input_file.read_to_string(&mut input).unwrap();
|
||||
|
||||
println!("{:?}", settings);
|
||||
println!("{}", settings.apply(input).unwrap());
|
||||
}
|
||||
|
11
src/opts.rs
Normal file
11
src/opts.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use clap::Clap;
|
||||
|
||||
#[derive(Clap, Debug)]
|
||||
#[clap(version = "0.1", author = "Lucien \"Phundrak\" Cartier-Tilet <lucien@phundrak.com>")]
|
||||
pub struct Opts {
|
||||
#[clap(short, long)]
|
||||
pub input: String,
|
||||
|
||||
#[clap(short, long)]
|
||||
pub settings: String,
|
||||
}
|
Loading…
Reference in New Issue
Block a user