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:
Lucien Cartier-Tilet 2020-07-12 13:06:28 +02:00
parent 2dec911b1e
commit fe6efa0b5c
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
4 changed files with 34 additions and 1 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
/target /target
*.log
*.txt
*.yaml

View File

@ -8,3 +8,4 @@ edition = "2018"
[dependencies] [dependencies]
lang-evolve-core = { path = "../lang-evolve-core"} lang-evolve-core = { path = "../lang-evolve-core"}
clap = "3.0.0-beta.1"

View File

@ -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() { 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
View 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,
}