2020-08-23 01:18:31 +02:00
use argh ::FromArgs ;
2020-08-24 01:51:59 +02:00
use std ::path ::PathBuf ;
2020-08-23 01:18:31 +02:00
#[ derive(FromArgs) ]
#[ argh(description = " Tool for gathering location data from Yepzon servers. " ) ]
pub struct EnvOpt {
2020-08-24 18:50:29 +02:00
#[ argh(
option ,
short = 'c' ,
description = " config.toml file path. " ,
default = " PathBuf::from( \" config.toml \" ) "
) ]
pub config : PathBuf ,
2020-08-23 01:18:31 +02:00
#[ argh(subcommand) ]
pub subcommand : Subcommand ,
}
#[ derive(FromArgs) ]
#[ argh(subcommand) ]
pub enum Subcommand {
2020-08-24 18:50:29 +02:00
Between ( BetweenOpt ) ,
2020-08-23 01:18:31 +02:00
Init ( InitOpt ) ,
2020-08-24 18:50:29 +02:00
Nick ( NickOpt ) ,
2020-08-23 01:18:31 +02:00
}
#[ derive(FromArgs) ]
2020-08-24 02:33:40 +02:00
#[ argh(
subcommand ,
2020-08-24 18:50:29 +02:00
name = " between " ,
description = " fetch locations for a given section in time. \n <tag> nickname, or index from nick list. \n since and until in format dd.mm.yyy, OR hh:mm:ss, OR dd.mm.yyy-hh:mm:ss "
2020-08-24 02:33:40 +02:00
) ]
2020-08-24 18:50:29 +02:00
pub struct BetweenOpt {
#[ argh(positional, description = " tag to be fetched " ) ]
pub tag : String ,
2020-08-24 01:51:59 +02:00
#[ argh(
option ,
2020-08-24 02:33:40 +02:00
short = 's' ,
description = " the oldest point in time to get locations from. "
) ]
pub since : String ,
#[ argh(
option ,
short = 'u' ,
description = " the most recent point in time to get locations from, default = now. "
) ]
pub until : Option < String > ,
2020-08-24 01:51:59 +02:00
}
2020-08-23 01:18:31 +02:00
#[ derive(FromArgs) ]
2020-08-24 02:33:40 +02:00
#[ argh(subcommand, name = " init " , description = " initializes a config file " ) ]
2020-08-23 01:18:31 +02:00
pub struct InitOpt { }
2020-08-24 18:50:29 +02:00
#[ derive(FromArgs) ]
#[ argh(subcommand, name = " nick " , description = " provides nicknaming to tags " ) ]
pub struct NickOpt {
#[ argh(subcommand) ]
pub subcommand : NickSub ,
}
#[ derive(FromArgs) ]
#[ argh(subcommand) ]
pub enum NickSub {
List ( NickListOpt ) ,
Set ( NickSetOpt ) ,
}
#[ derive(FromArgs) ]
#[ argh(
subcommand ,
name = " list " ,
description = " List all tags and their current nicknames "
) ]
pub struct NickListOpt { }
#[ derive(FromArgs) ]
#[ argh(
subcommand ,
name = " set " ,
description = " Set nickname for given tag index. see index with nick list "
) ]
pub struct NickSetOpt {
#[ argh(positional, description = " tag index, see index with nick list " ) ]
pub index : i32 ,
#[ argh(positional, description = " the new nickname for the tag " ) ]
pub nickname : String ,
}