Add api-key flag
This commit is contained in:
parent
a2a92d39eb
commit
3e535df8a8
@ -48,7 +48,14 @@ pub struct BetweenOpt {
|
||||
|
||||
#[derive(FromArgs)]
|
||||
#[argh(subcommand, name = "init", description = "initializes a config file")]
|
||||
pub struct InitOpt {}
|
||||
pub struct InitOpt {
|
||||
#[argh(
|
||||
option,
|
||||
short = 'a',
|
||||
description = "the API-key for the generated config-file"
|
||||
)]
|
||||
pub api_key: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
#[argh(
|
||||
|
10
src/main.rs
10
src/main.rs
@ -43,8 +43,11 @@ fn from_env(env: EnvOpt) -> Result<(), GenericError> {
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Subcommand::Init(_) => {
|
||||
let config = Config::default();
|
||||
Subcommand::Init(opt) => {
|
||||
let mut config = Config::default();
|
||||
if let Some(api_key) = opt.api_key {
|
||||
config.api_key = api_key;
|
||||
}
|
||||
config.write_to(&env.config)?;
|
||||
Ok(())
|
||||
}
|
||||
@ -52,7 +55,8 @@ fn from_env(env: EnvOpt) -> Result<(), GenericError> {
|
||||
let mut config = Config::from_path(&env.config)?;
|
||||
let mut api = API::new(config.clone());
|
||||
|
||||
let tags = api.get_tags()?;
|
||||
let mut tags = api.get_tags()?;
|
||||
tags.sort_by(|tag1, tag2| tag1.id.cmp(&tag2.id));
|
||||
|
||||
match opt.subcommand {
|
||||
NickSub::List(_) => {
|
||||
|
Loading…
Reference in New Issue
Block a user