mirror of
https://github.com/jht5945/finding.git
synced 2025-12-27 21:20:05 +08:00
first commit
This commit is contained in:
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "finding"
|
||||
version = "0.1.0"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
argparse = "0.2.2"
|
||||
rust_util = { git = "https://github.com/jht5945/rust_util" }
|
||||
35
src/main.rs
Normal file
35
src/main.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
extern crate argparse;
|
||||
extern crate rust_util;
|
||||
|
||||
use argparse::{ArgumentParser, StoreTrue, Store};
|
||||
use rust_util::*;
|
||||
|
||||
const VERSION: &str = "0.1";
|
||||
|
||||
fn print_version() {
|
||||
print!(r#"finding {}
|
||||
Copyright (C) 2019 Hatter Jiang.
|
||||
License MIT <https://opensource.org/licenses/MIT>
|
||||
|
||||
Written by Hatter Jiang
|
||||
"#, VERSION);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut version = false;
|
||||
let mut huge_file_size = String::from("100M");
|
||||
{
|
||||
let mut ap = ArgumentParser::new();
|
||||
ap.set_description("finding - command line find tool.");
|
||||
ap.refer(&mut huge_file_size).add_option(&["--huge-file"], Store, "Huge file size, default 100M");
|
||||
ap.refer(&mut version).add_option(&["-v", "--version"], StoreTrue, "Print version");
|
||||
ap.parse_args_or_exit();
|
||||
}
|
||||
|
||||
if version {
|
||||
print_version();
|
||||
return;
|
||||
}
|
||||
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Reference in New Issue
Block a user