mirror of
https://github.com/timvisee/ffsend.git
synced 2025-10-06 10:39:57 +02:00
Implement subcommand inferring based on calling name with feature flag
See issue timvisee/ffsend#24
This commit is contained in:
parent
1fc189d4d9
commit
a6deb9155b
5 changed files with 109 additions and 15 deletions
|
@ -1,3 +1,6 @@
|
|||
#[cfg(feature = "infer-command")]
|
||||
use std::collections::HashMap;
|
||||
|
||||
use ffsend_api::api::{DesiredVersion, Version};
|
||||
|
||||
/// The timeout for the Send client for generic requests, `0` to disable.
|
||||
|
@ -15,3 +18,19 @@ pub const API_VERSION_DESIRED_DEFAULT: DesiredVersion = DesiredVersion::Assume(A
|
|||
pub const API_VERSION_ASSUME: Version = Version::V3;
|
||||
#[cfg(not(feature = "send3"))]
|
||||
pub const API_VERSION_ASSUME: Version = Version::V2;
|
||||
|
||||
#[cfg(feature = "infer-command")]
|
||||
lazy_static! {
|
||||
/// Hashmap holding binary names to infer subcommands for.
|
||||
///
|
||||
/// When the `ffsend` binary is called with such a name, the corresponding subcommand is
|
||||
/// automatically inserted as argument. This also works when calling binaries through symbolic
|
||||
/// or hard links.
|
||||
pub static ref INFER_COMMANDS: HashMap<&'static str, &'static str> = {
|
||||
let mut m = HashMap::new();
|
||||
m.insert("ffput", "upload");
|
||||
m.insert("ffget", "download");
|
||||
m.insert("ffdel", "delete");
|
||||
m
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue