Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,28 @@ | ||
extern crate uuid; | ||
extern crate uuid_to_pokemon; | ||
extern crate structopt; | ||
#[macro_use] | ||
extern crate structopt_derive; | ||
|
||
use std::{env, process}; | ||
use uuid::Uuid; | ||
use uuid_to_pokemon::uuid_to_pokemon; | ||
use structopt::StructOpt; | ||
|
||
fn main() { | ||
let mut uuids: Vec<Uuid> = vec![]; | ||
let mut errors: Vec<String> = vec![]; | ||
|
||
for arg in env::args().skip(1) { | ||
match Uuid::parse_str(&arg) { | ||
Ok(u) => uuids.push(u), | ||
Err(_) => errors.push(arg), | ||
} | ||
} | ||
#[derive(StructOpt)] | ||
#[structopt(name = "UUID to POKEMON")] | ||
struct Opt { | ||
#[structopt(help = "List of UUIDs")] | ||
uuids: Vec<Uuid>, | ||
} | ||
|
||
if uuids.len() == 0 && errors.len() == 0 { | ||
uuids.push(Uuid::new_v4()); | ||
} | ||
fn main() { | ||
let mut opt = Opt::from_args(); | ||
|
||
if errors.len() > 0 { | ||
for e in errors { | ||
eprintln!("{} is not a valid UUID", e); | ||
} | ||
process::exit(1); | ||
if opt.uuids.len() == 0 { | ||
opt.uuids.push(Uuid::new_v4()); | ||
} | ||
|
||
for u in uuids { | ||
for u in opt.uuids { | ||
println!("{}\t{}", u, uuid_to_pokemon(u)); | ||
} | ||
} |