-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(writer): Create a seperate writer
Signed-off-by: dark0dave <dark0dave@mykolab.com>
- Loading branch information
Showing
9 changed files
with
314 additions
and
140 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,20 +1,45 @@ | ||
use clap::{ArgAction, Parser}; | ||
use std::path::PathBuf; | ||
|
||
use clap::{error::ErrorKind, ArgAction, Error, Parser}; | ||
|
||
#[derive(Parser, Debug)] | ||
#[clap(author, version, about, long_about = None)] | ||
pub struct Args { | ||
/// Game lang | ||
#[clap(long, value_parser, default_value = "en_US")] | ||
#[clap(env, short = 'l', long, value_parser, default_value = "en_US")] | ||
pub game_lang: String, | ||
/// Flag to process tiles | ||
#[clap(long, short, action=ArgAction::SetTrue)] | ||
#[clap(env, long, short, action=ArgAction::SetTrue)] | ||
pub tiles: bool, | ||
/// Flag to tlk file | ||
#[clap(long, short, action=ArgAction::SetFalse)] | ||
#[clap(env, long, short, action=ArgAction::SetTrue)] | ||
pub process_tlk: bool, | ||
/// Json Output | ||
#[clap(long, short, action=ArgAction::SetTrue)] | ||
pub json: bool, | ||
/// Output Format, expects json(j), binary(b), print(p), or none(empty value) | ||
#[clap(env, long, short, value_parser=output_format_parser, default_value = "")] | ||
pub output_format: String, | ||
/// Filename or prefix to extract [WARNING: EXPERIMENTAL] | ||
#[clap(env, long, short, default_value = "")] | ||
pub extract: String, | ||
/// Turn a json into an ie file type [WARNING: EXPERIMENTAL] | ||
#[clap(env, short='i', long, action=ArgAction::SetTrue)] | ||
pub to_ie_type: bool, | ||
/// Read Save game | ||
#[clap(env, long, short, action=ArgAction::SetTrue)] | ||
pub save: bool, | ||
/// Read Save game | ||
#[clap(env, long, short, default_value = ".")] | ||
pub destination: PathBuf, | ||
/// The path to the file to read | ||
pub resource_file_or_dir: std::path::PathBuf, | ||
#[clap(env, long, short)] | ||
pub resource_file_or_dir: PathBuf, | ||
} | ||
|
||
fn output_format_parser(input: &str) -> Result<String, clap::Error> { | ||
match input.to_lowercase().as_str() { | ||
"json" | "j" => Ok("json".to_string()), | ||
"binary" | "bin" | "b" => Ok("binary".to_string()), | ||
"" | "n" | "no" | "none" => Ok("".to_string()), | ||
"p" | "print" => Ok("print".to_string()), | ||
_ => Err(Error::new(ErrorKind::ValueValidation)), | ||
} | ||
} |
Oops, something went wrong.