mirror of
https://github.com/denoland/deno.git
synced 2025-10-01 22:51:14 +00:00
fix: add info suggestion for unsafely-ignore-certificate-errors
and add --help=full
(#28203)
For #27865
This commit is contained in:
parent
bc71eb9541
commit
0fbab02d0f
6 changed files with 72 additions and 58 deletions
|
@ -1257,7 +1257,9 @@ pub fn flags_from_vec(args: Vec<OsString>) -> clap::error::Result<Flags> {
|
|||
app
|
||||
};
|
||||
|
||||
if help_expansion == "unstable"
|
||||
if help_expansion == "full" {
|
||||
subcommand = enable_full(subcommand);
|
||||
} else if help_expansion == "unstable"
|
||||
&& subcommand
|
||||
.get_arguments()
|
||||
.any(|arg| arg.get_id().as_str() == "unstable")
|
||||
|
@ -1423,6 +1425,17 @@ fn enable_unstable(command: Command) -> Command {
|
|||
})
|
||||
}
|
||||
|
||||
fn enable_full(command: Command) -> Command {
|
||||
command.mut_args(|arg| {
|
||||
let long_help = arg.get_long_help();
|
||||
if !long_help.is_some_and(|s| s.to_string() == "false") {
|
||||
arg.hide(false)
|
||||
} else {
|
||||
arg
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
macro_rules! heading {
|
||||
($($name:ident = $title:expr),+; $total:literal) => {
|
||||
$(const $name: &str = $title;)+
|
||||
|
@ -1547,11 +1560,11 @@ pub fn clap_root() -> Command {
|
|||
Arg::new("help")
|
||||
.short('h')
|
||||
.long("help")
|
||||
.hide(true)
|
||||
.action(ArgAction::Append)
|
||||
.num_args(0..=1)
|
||||
.require_equals(true)
|
||||
.value_parser(["unstable"])
|
||||
.value_name("CONTEXT")
|
||||
.value_parser(["unstable", "full"])
|
||||
.global(true),
|
||||
)
|
||||
.arg(
|
||||
|
@ -3464,7 +3477,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.action(ArgAction::Append)
|
||||
.require_equals(true)
|
||||
.value_name("PATH")
|
||||
.help("Allow file system read access. Optionally specify allowed paths")
|
||||
.long_help("false")
|
||||
.value_hint(ValueHint::AnyPath)
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
|
@ -3481,7 +3494,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.action(ArgAction::Append)
|
||||
.require_equals(true)
|
||||
.value_name("PATH")
|
||||
.help("Deny file system read access. Optionally specify denied paths")
|
||||
.long_help("false")
|
||||
.value_hint(ValueHint::AnyPath)
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
|
@ -3499,7 +3512,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.action(ArgAction::Append)
|
||||
.require_equals(true)
|
||||
.value_name("PATH")
|
||||
.help("Allow file system write access. Optionally specify allowed paths")
|
||||
.long_help("false")
|
||||
.value_hint(ValueHint::AnyPath)
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
|
@ -3516,7 +3529,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.action(ArgAction::Append)
|
||||
.require_equals(true)
|
||||
.value_name("PATH")
|
||||
.help("Deny file system write access. Optionally specify denied paths")
|
||||
.long_help("false")
|
||||
.value_hint(ValueHint::AnyPath)
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
|
@ -3534,7 +3547,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("IP_OR_HOSTNAME")
|
||||
.help("Allow network access. Optionally specify allowed IP addresses and host names, with ports as necessary")
|
||||
.long_help("false")
|
||||
.value_parser(flags_net::validator)
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
|
@ -3551,10 +3564,9 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("IP_OR_HOSTNAME")
|
||||
.help("Deny network access. Optionally specify denied IP addresses and host names, with ports as necessary")
|
||||
.long_help("false")
|
||||
.value_parser(flags_net::validator)
|
||||
.hide(true)
|
||||
;
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -3570,7 +3582,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("VARIABLE_NAME")
|
||||
.help("Allow access to system environment information. Optionally specify accessible environment variables")
|
||||
.long_help("false")
|
||||
.value_parser(|key: &str| {
|
||||
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
|
||||
return Err(format!("invalid key \"{key}\""));
|
||||
|
@ -3582,8 +3594,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
key.to_string()
|
||||
})
|
||||
})
|
||||
.hide(true)
|
||||
;
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -3598,7 +3609,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("VARIABLE_NAME")
|
||||
.help("Deny access to system environment information. Optionally specify accessible environment variables")
|
||||
.long_help("false")
|
||||
.value_parser(|key: &str| {
|
||||
if key.is_empty() || key.contains(&['=', '\0'] as &[char]) {
|
||||
return Err(format!("invalid key \"{key}\""));
|
||||
|
@ -3610,8 +3621,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
key.to_string()
|
||||
})
|
||||
})
|
||||
.hide(true)
|
||||
;
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -3627,10 +3637,9 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("API_NAME")
|
||||
.help("Allow access to OS information. Optionally allow specific APIs by function name")
|
||||
.long_help("false")
|
||||
.value_parser(|key: &str| SysDescriptor::parse(key.to_string()).map(|s| s.into_string()))
|
||||
.hide(true)
|
||||
;
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -3645,10 +3654,9 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("API_NAME")
|
||||
.help("Deny access to OS information. Optionally deny specific APIs by function name")
|
||||
.long_help("false")
|
||||
.value_parser(|key: &str| SysDescriptor::parse(key.to_string()).map(|s| s.into_string()))
|
||||
.hide(true)
|
||||
;
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -3663,9 +3671,8 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("PROGRAM_NAME")
|
||||
.help("Allow running subprocesses. Optionally specify allowed runnable program names")
|
||||
.hide(true)
|
||||
;
|
||||
.long_help("false")
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -3680,9 +3687,8 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.use_value_delimiter(true)
|
||||
.require_equals(true)
|
||||
.value_name("PROGRAM_NAME")
|
||||
.help("Deny running subprocesses. Optionally specify denied runnable program names")
|
||||
.hide(true)
|
||||
;
|
||||
.long_help("false")
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -3698,7 +3704,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.action(ArgAction::Append)
|
||||
.require_equals(true)
|
||||
.value_name("PATH")
|
||||
.help("(Unstable) Allow loading dynamic libraries. Optionally specify allowed directories or files")
|
||||
.long_help("false")
|
||||
.value_hint(ValueHint::AnyPath)
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
|
@ -3715,7 +3721,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.action(ArgAction::Append)
|
||||
.require_equals(true)
|
||||
.value_name("PATH")
|
||||
.help("(Unstable) Deny loading dynamic libraries. Optionally specify denied directories or files")
|
||||
.long_help("false")
|
||||
.value_hint(ValueHint::AnyPath)
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
|
@ -3729,7 +3735,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
let mut arg = Arg::new("allow-hrtime")
|
||||
.long("allow-hrtime")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("REMOVED in Deno 2.0")
|
||||
.long_help("false")
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
|
@ -3742,7 +3748,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
let mut arg = Arg::new("deny-hrtime")
|
||||
.long("deny-hrtime")
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("REMOVED in Deno 2.0")
|
||||
.long_help("false")
|
||||
.hide(true);
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
|
@ -3756,7 +3762,7 @@ fn permission_args(app: Command, requires: Option<&'static str>) -> Command {
|
|||
.long("no-prompt")
|
||||
.action(ArgAction::SetTrue)
|
||||
.hide(true)
|
||||
.help("Always throw if required permission wasn't passed");
|
||||
.long_help("false");
|
||||
if let Some(requires) = requires {
|
||||
arg = arg.requires(requires)
|
||||
}
|
||||
|
@ -4623,11 +4629,11 @@ fn completions_parse(
|
|||
matches: &mut ArgMatches,
|
||||
mut app: Command,
|
||||
) {
|
||||
use clap_complete::generate;
|
||||
use clap_complete::shells::Bash;
|
||||
use clap_complete::shells::Fish;
|
||||
use clap_complete::shells::PowerShell;
|
||||
use clap_complete::shells::Zsh;
|
||||
use clap_complete::aot::generate;
|
||||
use clap_complete::aot::Bash;
|
||||
use clap_complete::aot::Fish;
|
||||
use clap_complete::aot::PowerShell;
|
||||
use clap_complete::aot::Zsh;
|
||||
use clap_complete_fig::Fig;
|
||||
|
||||
let mut buf: Vec<u8> = vec![];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue