yepzon-locationer/src/cmd.rs

91 lines
2.2 KiB
Rust

use argh::FromArgs;
use std::path::PathBuf;
#[derive(FromArgs)]
#[argh(description = "Tool for gathering location data from Yepzon servers.")]
pub struct EnvOpt {
#[argh(
option,
short = 'c',
description = "config.toml file path.",
default = "PathBuf::from(\"config.toml\")"
)]
pub config: PathBuf,
#[argh(subcommand)]
pub subcommand: Subcommand,
}
#[derive(FromArgs)]
#[argh(subcommand)]
pub enum Subcommand {
Between(BetweenOpt),
Init(InitOpt),
Nick(NickOpt),
}
#[derive(FromArgs)]
#[argh(
subcommand,
name = "between",
description = "fetch locations for a given section in time.\n<device> nickname, or index from nick list.\nsince and until in format dd.mm.yyy, OR hh:mm:ss, OR dd.mm.yyy-hh:mm:ss"
)]
pub struct BetweenOpt {
#[argh(positional, description = "device to be fetched")]
pub device: String, // Device = tag, but in human speech
#[argh(
option,
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>,
}
#[derive(FromArgs)]
#[argh(subcommand, name = "init", description = "initializes a config file")]
pub struct InitOpt {}
#[derive(FromArgs)]
#[argh(
subcommand,
name = "nick",
description = "provides nicknaming to devices"
)]
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 devices and their current nicknames"
)]
pub struct NickListOpt {}
#[derive(FromArgs)]
#[argh(
subcommand,
name = "set",
description = "Set nickname for given device index. see index with nick list"
)]
pub struct NickSetOpt {
#[argh(positional, description = "device index, see index with nick list")]
pub index: i32,
#[argh(positional, description = "the new nickname for the device")]
pub nickname: String,
}