parent
6ff81c35e3
commit
c9e04ddb33
4 changed files with 62 additions and 0 deletions
1
q-pilater/.gitignore
vendored
Normal file
1
q-pilater/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target/
|
25
q-pilater/Cargo.lock
generated
Normal file
25
q-pilater/Cargo.lock
generated
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getopts"
|
||||||
|
version = "0.2.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "q-pilater"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"getopts",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
|
7
q-pilater/Cargo.toml
Normal file
7
q-pilater/Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[package]
|
||||||
|
name = "q-pilater"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
getopts = "0.2"
|
29
q-pilater/src/main.rs
Normal file
29
q-pilater/src/main.rs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
extern crate getopts;
|
||||||
|
use getopts::Options;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
fn print_usage(program: &str, opts: Options) {
|
||||||
|
let brief = format!("Usage: {} FILE [options]", program);
|
||||||
|
print!("{}", opts.usage(&brief));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
let program = args[0].clone();
|
||||||
|
let mut opts = Options::new();
|
||||||
|
|
||||||
|
// List args
|
||||||
|
opts.optopt("i","","interpreter mode","DIRECTORY");
|
||||||
|
opts.optflag("h", "help", "print this help menu");
|
||||||
|
|
||||||
|
// parse args
|
||||||
|
let matches = match opts.parse(&args[1..]) {
|
||||||
|
Ok(m) => { m }
|
||||||
|
Err(f) => { panic!("{}",f.to_string()) }
|
||||||
|
};
|
||||||
|
|
||||||
|
if matches.opt_present("h") {
|
||||||
|
print_usage(&program, opts);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue