diff --git a/Cargo.toml b/Cargo.toml index d50ddf1..65a3ebb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fie" -version = "0.4.0" +version = "0.5.0" authors = ["Douman "] repository = "https://github.com/DoumanAsh/fie" description = "Small and cute twitter app." diff --git a/README.md b/README.md index 2cb5335..be7884b 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,6 @@ Use [example](fie.toml) as reference. ## Usage ``` -Douman - Small and cute twitter app. USAGE: @@ -37,8 +35,9 @@ FLAGS: -V, --version Prints version information SUBCOMMANDS: + env Prints information about app environment. help Prints this message or the help of the given subcommand(s) - post Creates new tweet + post Creates new tweet. ``` ### post @@ -63,4 +62,20 @@ ARGS: Message content ``` +### env + +Prints information about app's environment. + +``` +Prints information about app environment. + +USAGE: + fie.exe env [SUBCOMMAND] +FLAGS: + -h, --help Prints help information + +SUBCOMMANDS: + config Prints path to config file. + help Prints this message or the help of the given subcommand(s) +``` diff --git a/src/cli.rs b/src/cli.rs index db37cac..fcd30e2 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -30,8 +30,8 @@ const ABOUT: &'static str = " Small and cute twitter app."; #[inline(always)] -fn new_command() -> App<'static, 'static> { - SubCommand::with_name("post").about("Creates new tweet") +fn post_command() -> App<'static, 'static> { + SubCommand::with_name("post").about("Creates new tweet.") .arg(arg("message").required(true) .help("Message content")) .arg(arg("tag").short("t") @@ -45,19 +45,39 @@ fn new_command() -> App<'static, 'static> { .help("Adds image to post. Normally up to 4.")) } +#[inline(always)] +fn env_config_command() -> App<'static, 'static> { + SubCommand::with_name("config").about("Prints path to config file.") +} + +#[inline(always)] +fn env_command() -> App<'static, 'static> { + SubCommand::with_name("env").about("Prints information about app environment.") + .setting(AppSettings::ArgRequiredElseHelp) + .subcommand(env_config_command()) +} + pub fn parser() -> App<'static, 'static> { App::new(NAME).about(ABOUT) .author(AUTHOR) .version(VERSION) .setting(AppSettings::ArgRequiredElseHelp) .setting(AppSettings::VersionlessSubcommands) - .subcommand(new_command()) .arg(flag("gab").help("Use gab.ai. By default all social medias are used unless flag is specified.")) .arg(flag("twitter").help("Use Twitter. By default all social medias are used unless flag is specified.")) .arg(flag("minds").help("Use Minds.com. By default all social medias are used unless flag is specified.")) + .subcommand(post_command()) + .subcommand(env_command()) } +#[derive(Debug)] +///Env subcommand variants +pub enum EnvCommand { + ///Prints configuration file. + Config +} + #[derive(Debug)] ///Command representation with all its arguments. pub enum Commands { @@ -66,9 +86,11 @@ pub enum Commands { ///# Parameters: /// ///* First - Text. - ///* Second - Tags. - ///* Third - Image to attach. - Post(String, Option>) + ///* Second - Images to attach. + Post(String, Option>), + ///Prints environment information. + Env(EnvCommand) + } impl Commands { @@ -87,6 +109,12 @@ impl Commands { Commands::Post(message, image) }, + "env" => { + match matches.subcommand() { + ("config", _) => Commands::Env(EnvCommand::Config), + _ => unimplemented!() + } + } _ => unimplemented!() } } diff --git a/src/main.rs b/src/main.rs index 76cf821..09c8ba3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,8 @@ fn init_api<'a>(mut tokio_core: &mut Core, http: &'a api::http::HttpClient, conf } fn run() -> Result { - let config = config::Config::from_file(&utils::get_config())?; + let config_path = utils::get_config(); + let config = config::Config::from_file(&config_path)?; let args = cli::Args::new(config.platforms)?; let config = ApiConfigs { gab: config.gab, @@ -141,6 +142,11 @@ fn run() -> Result { } tokio_core.run(futures::future::join_all(jobs)).unwrap(); + }, + cli::Commands::Env(env) => { + match env { + cli::EnvCommand::Config => println!("{}", config_path.display()), + } } };