зеркало из https://github.com/mozilla/sccache.git
Remove requirement on clap/derive
This commit is contained in:
Родитель
cdd94486a1
Коммит
4528af20e2
|
@ -283,6 +283,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"terminal_size",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
|
@ -540,6 +541,27 @@ dependencies = [
|
|||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
|
||||
dependencies = [
|
||||
"errno-dragonfly",
|
||||
"libc",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "errno-dragonfly"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "error-chain"
|
||||
version = "0.12.4"
|
||||
|
@ -1048,6 +1070,12 @@ dependencies = [
|
|||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-lifetimes"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06"
|
||||
|
||||
[[package]]
|
||||
name = "ipnet"
|
||||
version = "2.3.1"
|
||||
|
@ -1152,6 +1180,12 @@ version = "0.5.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.0.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"
|
||||
|
||||
[[package]]
|
||||
name = "local-encoding"
|
||||
version = "0.2.0"
|
||||
|
@ -1954,6 +1988,20 @@ dependencies = [
|
|||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.35.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbb2fda4666def1433b1b05431ab402e42a1084285477222b72d6c564c417cef"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"io-lifetimes",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.9"
|
||||
|
@ -2415,6 +2463,16 @@ dependencies = [
|
|||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8440c860cf79def6164e4a0a983bcc2305d82419177a0e0c71930d049e3ac5a1"
|
||||
dependencies = [
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termtree"
|
||||
version = "0.2.4"
|
||||
|
@ -2426,6 +2484,9 @@ name = "textwrap"
|
|||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16"
|
||||
dependencies = [
|
||||
"terminal_size",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thirtyfour"
|
||||
|
|
|
@ -29,7 +29,7 @@ blake3 = "1"
|
|||
byteorder = "1.0"
|
||||
bytes = "1"
|
||||
chrono = { version = "0.4.22", optional = true }
|
||||
clap = { version = "3.2.22", features = ["derive"] }
|
||||
clap = { version = "3.2.22", features = ["derive", "env", "wrap_help"] }
|
||||
directories = "4.0.1"
|
||||
env_logger = "0.9"
|
||||
filetime = "0.2"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::{env, ffi::OsString, fmt, net::SocketAddr, path::PathBuf, str::FromStr};
|
||||
|
||||
use anyhow::bail;
|
||||
use clap::{Arg, ArgEnum, ArgGroup, Command as ClapCommand, PossibleValue};
|
||||
use clap::{Arg, ArgGroup, Command as ClapCommand};
|
||||
use sccache::{config, dist::ServerId};
|
||||
use syslog::Facility;
|
||||
|
||||
|
@ -46,7 +46,7 @@ impl fmt::Display for TokenBits {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Copy)]
|
||||
#[derive(Clone, Copy)]
|
||||
enum LogLevel {
|
||||
Error,
|
||||
Warn,
|
||||
|
@ -56,10 +56,24 @@ enum LogLevel {
|
|||
}
|
||||
|
||||
impl LogLevel {
|
||||
fn possible_values() -> impl Iterator<Item = PossibleValue<'static>> {
|
||||
Self::value_variants()
|
||||
.iter()
|
||||
.filter_map(ArgEnum::to_possible_value)
|
||||
fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Error => "error",
|
||||
Self::Warn => "warn",
|
||||
Self::Info => "info",
|
||||
Self::Debug => "debug",
|
||||
Self::Trace => "trace",
|
||||
}
|
||||
}
|
||||
|
||||
fn values() -> &'static [Self] {
|
||||
&[
|
||||
Self::Error,
|
||||
Self::Warn,
|
||||
Self::Info,
|
||||
Self::Debug,
|
||||
Self::Trace,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +131,7 @@ fn get_clap_command() -> ClapCommand<'static> {
|
|||
let syslog = flag_infer_long("syslog")
|
||||
.help("Log to the syslog with LEVEL")
|
||||
.value_name("LEVEL")
|
||||
.possible_values(LogLevel::possible_values());
|
||||
.possible_values(LogLevel::values().iter().map(LogLevel::as_str));
|
||||
let config_with_help_message =
|
||||
|help: &'static str| flag_infer_long("config").help(help).value_name("PATH");
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
use crate::errors::*;
|
||||
use clap::{Arg, ArgEnum, ArgGroup, ErrorKind, PossibleValue};
|
||||
use clap::{Arg, ArgGroup, ErrorKind};
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
|
@ -22,21 +22,22 @@ use which::which_in;
|
|||
|
||||
const ENV_VAR_INTERNAL_START_SERVER: &str = "SCCACHE_START_SERVER";
|
||||
|
||||
#[derive(ArgEnum, Debug, Clone)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum StatsFormat {
|
||||
Text,
|
||||
Json,
|
||||
}
|
||||
|
||||
impl StatsFormat {
|
||||
fn default_str() -> &'static str {
|
||||
"text"
|
||||
fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Text => "text",
|
||||
Self::Json => "json",
|
||||
}
|
||||
}
|
||||
|
||||
fn possible_values() -> impl Iterator<Item = PossibleValue<'static>> {
|
||||
Self::value_variants()
|
||||
.iter()
|
||||
.filter_map(ArgEnum::to_possible_value)
|
||||
fn values() -> &'static [Self] {
|
||||
&[Self::Text, Self::Json]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,6 +53,12 @@ impl FromStr for StatsFormat {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for StatsFormat {
|
||||
fn default() -> Self {
|
||||
Self::Text
|
||||
}
|
||||
}
|
||||
|
||||
/// A specific command to run.
|
||||
pub enum Command {
|
||||
/// Show cache statistics and exit.
|
||||
|
@ -129,8 +136,8 @@ fn get_clap_command() -> clap::Command<'static> {
|
|||
flag_infer_long("stats-format")
|
||||
.help("set output format of statistics")
|
||||
.value_name("FMT")
|
||||
.possible_values(StatsFormat::possible_values())
|
||||
.default_value(StatsFormat::default_str()),
|
||||
.possible_values(StatsFormat::values().iter().map(StatsFormat::as_str))
|
||||
.default_value(StatsFormat::default().as_str()),
|
||||
Arg::new("CMD")
|
||||
.multiple_occurrences(true)
|
||||
.use_value_delimiter(false),
|
||||
|
|
Загрузка…
Ссылка в новой задаче