aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs
index f990319..d8e66a1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,5 @@
extern crate base64;
+extern crate byteorder;
extern crate clap;
extern crate image;
extern crate imageproc;
@@ -11,8 +12,6 @@ extern crate rusttype;
extern crate termcolor;
extern crate toml;
extern crate xdg;
-#[macro_use]
-extern crate lazy_static;
use std::error::Error as StdError;
use std::fmt;
@@ -39,7 +38,7 @@ mod useropts;
use clap::{App, Arg, ArgMatches};
use api::{Api, Profession, Skill};
-use bt::{BuildTemplate, ExtraData, Legend, TraitChoice, Traitline};
+use bt::{BuildTemplate, ExtraData, Legend, TraitChoice, Traitline, CODE_REVENANT};
use render::RenderError;
/// The name of this application.
@@ -184,10 +183,6 @@ fn run_searching(api: &mut Api, matches: &ArgMatches) -> MainResult<BuildTemplat
.expect("clap handles missing argument");
let profession = find_profession(api, requested_profession)?;
- let prof_enum = profession
- .name
- .parse()
- .expect("Profession object has unparseable name");
let legends = matches
.values_of("legend")
@@ -198,7 +193,7 @@ fn run_searching(api: &mut Api, matches: &ArgMatches) -> MainResult<BuildTemplat
.map(Result::unwrap)
.collect::<Vec<_>>();
- let extra_data = if prof_enum == bt::Profession::Revenant {
+ let extra_data = if profession.code == CODE_REVENANT {
let mut array_legends = [Legend::None; 4];
for (i, l) in legends.iter().enumerate() {
array_legends[i] = *l;
@@ -208,7 +203,7 @@ fn run_searching(api: &mut Api, matches: &ArgMatches) -> MainResult<BuildTemplat
ExtraData::None
};
- let skills = if prof_enum != bt::Profession::Revenant {
+ let skills = if profession.code != CODE_REVENANT {
matches
.values_of("skill")
.map(Iterator::collect::<Vec<_>>)
@@ -242,7 +237,7 @@ fn run_searching(api: &mut Api, matches: &ArgMatches) -> MainResult<BuildTemplat
"got too many traitlines"
);
- let build = BuildTemplate::new(prof_enum, &skills, &traitlines, extra_data)
+ let build = BuildTemplate::new(profession, &skills, &traitlines, extra_data)
.expect("BuildTemplate could not be constructed");
Ok(build)
@@ -348,6 +343,12 @@ fn run() -> MainResult<()> {
.takes_value(true),
)
.arg(
+ Arg::with_name("no-cache")
+ .help("Disables the cache")
+ .long("no-cache")
+ .takes_value(false),
+ )
+ .arg(
Arg::with_name("config")
.help("Specifies the render option file.")
.long("config")
@@ -355,7 +356,11 @@ fn run() -> MainResult<()> {
)
.get_matches();
- let mut api = Api::new(cache::FileCache::new());
+ let mut api = if matches.is_present("no-cache") {
+ Api::new(cache::NoopCache::new())
+ } else {
+ Api::new(cache::FileCache::new())
+ };
let build = if matches.is_present("chatlink") {
run_chatlink(&mut api, &matches)?
} else {