update clap to v3: install
This commit is contained in:
@@ -14,7 +14,7 @@ atty = "0.2.11"
|
|||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
bzip2 = "0.4.3"
|
bzip2 = "0.4.3"
|
||||||
chrono = { version = "0.4.11", features = ["serde"] }
|
chrono = { version = "0.4.11", features = ["serde"] }
|
||||||
clap = { version = "3.1.5" }
|
clap = { version = "3.1.5", features = ["cargo"] }
|
||||||
console = "0.15.0"
|
console = "0.15.0"
|
||||||
ctrlc = { version = "3.2.1", features = ["termination"] }
|
ctrlc = { version = "3.2.1", features = ["termination"] }
|
||||||
crossbeam-channel = "0.5"
|
crossbeam-channel = "0.5"
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
use {
|
use {
|
||||||
clap::{crate_description, crate_name, App, AppSettings, Arg, ArgMatches, SubCommand},
|
clap::{crate_description, crate_name, Arg, ArgMatches, Command},
|
||||||
solana_clap_utils::{
|
solana_clap_utils::{
|
||||||
input_parsers::pubkey_of,
|
input_parsers::pubkey_of,
|
||||||
input_validators::{is_pubkey, is_url},
|
input_validators::{is_pubkey, is_url},
|
||||||
@@ -38,10 +38,7 @@ pub fn is_explicit_release(string: String) -> Result<(), String> {
|
|||||||
is_semver(&string).or_else(|_| is_release_channel(&string))
|
is_semver(&string).or_else(|_| is_release_channel(&string))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn explicit_release_of(
|
pub fn explicit_release_of(matches: &ArgMatches, name: &str) -> Option<config::ExplicitRelease> {
|
||||||
matches: &ArgMatches<'_>,
|
|
||||||
name: &str,
|
|
||||||
) -> Option<config::ExplicitRelease> {
|
|
||||||
matches
|
matches
|
||||||
.value_of(name)
|
.value_of(name)
|
||||||
.map(ToString::to_string)
|
.map(ToString::to_string)
|
||||||
@@ -58,7 +55,7 @@ pub fn explicit_release_of(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_init(matches: &ArgMatches<'_>, config_file: &str) -> Result<(), String> {
|
fn handle_init(matches: &ArgMatches, config_file: &str) -> Result<(), String> {
|
||||||
let json_rpc_url = matches.value_of("json_rpc_url").unwrap();
|
let json_rpc_url = matches.value_of("json_rpc_url").unwrap();
|
||||||
let update_manifest_pubkey = pubkey_of(matches, "update_manifest_pubkey");
|
let update_manifest_pubkey = pubkey_of(matches, "update_manifest_pubkey");
|
||||||
let data_dir = matches.value_of("data_dir").unwrap();
|
let data_dir = matches.value_of("data_dir").unwrap();
|
||||||
@@ -85,13 +82,14 @@ fn handle_init(matches: &ArgMatches<'_>, config_file: &str) -> Result<(), String
|
|||||||
pub fn main() -> Result<(), String> {
|
pub fn main() -> Result<(), String> {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
|
||||||
let matches = App::new(crate_name!())
|
let matches = Command::new(crate_name!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.version(solana_version::version!())
|
.version(solana_version::version!())
|
||||||
.setting(AppSettings::SubcommandRequiredElseHelp)
|
.subcommand_required(true)
|
||||||
|
.arg_required_else_help(true)
|
||||||
.arg({
|
.arg({
|
||||||
let arg = Arg::with_name("config_file")
|
let arg = Arg::new("config_file")
|
||||||
.short("c")
|
.short('c')
|
||||||
.long("config")
|
.long("config")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
@@ -103,12 +101,12 @@ pub fn main() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("init")
|
Command::new("init")
|
||||||
.about("initializes a new installation")
|
.about("initializes a new installation")
|
||||||
.setting(AppSettings::DisableVersion)
|
.disable_version_flag(true)
|
||||||
.arg({
|
.arg({
|
||||||
let arg = Arg::with_name("data_dir")
|
let arg = Arg::new("data_dir")
|
||||||
.short("d")
|
.short('d')
|
||||||
.long("data-dir")
|
.long("data-dir")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
@@ -120,61 +118,61 @@ pub fn main() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("json_rpc_url")
|
Arg::new("json_rpc_url")
|
||||||
.short("u")
|
.short('u')
|
||||||
.long("url")
|
.long("url")
|
||||||
.value_name("URL")
|
.value_name("URL")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value(defaults::JSON_RPC_URL)
|
.default_value(defaults::JSON_RPC_URL)
|
||||||
.validator(is_url)
|
.validator(|s| is_url(s))
|
||||||
.help("JSON RPC URL for the solana cluster"),
|
.help("JSON RPC URL for the solana cluster"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no_modify_path")
|
Arg::new("no_modify_path")
|
||||||
.long("no-modify-path")
|
.long("no-modify-path")
|
||||||
.help("Don't configure the PATH environment variable"),
|
.help("Don't configure the PATH environment variable"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("update_manifest_pubkey")
|
Arg::new("update_manifest_pubkey")
|
||||||
.short("p")
|
.short('p')
|
||||||
.long("pubkey")
|
.long("pubkey")
|
||||||
.value_name("PUBKEY")
|
.value_name("PUBKEY")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.validator(is_pubkey)
|
.validator(|s| is_pubkey(s.to_string()))
|
||||||
.help("Public key of the update manifest"),
|
.help("Public key of the update manifest"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("explicit_release")
|
Arg::new("explicit_release")
|
||||||
.value_name("release")
|
.value_name("release")
|
||||||
.index(1)
|
.index(1)
|
||||||
.conflicts_with_all(&["json_rpc_url", "update_manifest_pubkey"])
|
.conflicts_with_all(&["json_rpc_url", "update_manifest_pubkey"])
|
||||||
.validator(is_explicit_release)
|
.validator(|s| is_explicit_release(s.to_string()))
|
||||||
.help("The release version or channel to install"),
|
.help("The release version or channel to install"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("info")
|
Command::new("info")
|
||||||
.about("Displays information about the current installation")
|
.about("Displays information about the current installation")
|
||||||
.setting(AppSettings::DisableVersion)
|
.disable_version_flag(true)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("local_info_only")
|
Arg::new("local_info_only")
|
||||||
.short("l")
|
.short('l')
|
||||||
.long("local")
|
.long("local")
|
||||||
.help("only display local information, don't check for updates"),
|
.help("only display local information, don't check for updates"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("eval")
|
Arg::new("eval")
|
||||||
.long("eval")
|
.long("eval")
|
||||||
.help("display information in a format that can be used with `eval`"),
|
.help("display information in a format that can be used with `eval`"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("deploy")
|
Command::new("deploy")
|
||||||
.about("Deploys a new update")
|
.about("Deploys a new update")
|
||||||
.setting(AppSettings::DisableVersion)
|
.disable_version_flag(true)
|
||||||
.arg({
|
.arg({
|
||||||
let arg = Arg::with_name("from_keypair_file")
|
let arg = Arg::new("from_keypair_file")
|
||||||
.short("k")
|
.short('k')
|
||||||
.long("keypair")
|
.long("keypair")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
@@ -186,54 +184,55 @@ pub fn main() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("json_rpc_url")
|
Arg::new("json_rpc_url")
|
||||||
.short("u")
|
.short('u')
|
||||||
.long("url")
|
.long("url")
|
||||||
.value_name("URL")
|
.value_name("URL")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value(defaults::JSON_RPC_URL)
|
.default_value(defaults::JSON_RPC_URL)
|
||||||
.validator(is_url)
|
.validator(|s| is_url(s))
|
||||||
.help("JSON RPC URL for the solana cluster"),
|
.help("JSON RPC URL for the solana cluster"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("download_url")
|
Arg::new("download_url")
|
||||||
.index(1)
|
.index(1)
|
||||||
.required(true)
|
.required(true)
|
||||||
.validator(is_url)
|
.validator(|s| is_url(s))
|
||||||
.help("URL to the solana release archive"),
|
.help("URL to the solana release archive"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("update_manifest_keypair_file")
|
Arg::new("update_manifest_keypair_file")
|
||||||
.index(2)
|
.index(2)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("Keypair file for the update manifest (/path/to/keypair.json)"),
|
.help("Keypair file for the update manifest (/path/to/keypair.json)"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("gc")
|
Command::new("gc")
|
||||||
.about("Delete older releases from the install cache to reclaim disk space")
|
.about("Delete older releases from the install cache to reclaim disk space")
|
||||||
.setting(AppSettings::DisableVersion),
|
.disable_version_flag(true),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("update")
|
Command::new("update")
|
||||||
.about("Checks for an update, and if available downloads and applies it")
|
.about("Checks for an update, and if available downloads and applies it")
|
||||||
.setting(AppSettings::DisableVersion),
|
.disable_version_flag(true),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("run")
|
Command::new("run")
|
||||||
.about("Runs a program while periodically checking and applying software updates")
|
.about("Runs a program while periodically checking and applying software updates")
|
||||||
.after_help("The program will be restarted upon a successful software update")
|
.after_help("The program will be restarted upon a successful software update")
|
||||||
.setting(AppSettings::DisableVersion)
|
.disable_version_flag(true)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("program_name")
|
Arg::new("program_name")
|
||||||
.index(1)
|
.index(1)
|
||||||
.required(true)
|
.required(true)
|
||||||
.help("program to run"),
|
.help("program to run"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("program_arguments")
|
Arg::new("program_arguments")
|
||||||
.index(2)
|
.index(2)
|
||||||
.multiple(true)
|
.multiple_occurrences(true)
|
||||||
|
.multiple_values(true)
|
||||||
.help("arguments to supply to the program"),
|
.help("arguments to supply to the program"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -242,13 +241,13 @@ pub fn main() -> Result<(), String> {
|
|||||||
let config_file = matches.value_of("config_file").unwrap();
|
let config_file = matches.value_of("config_file").unwrap();
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
("init", Some(matches)) => handle_init(matches, config_file),
|
Some(("init", matches)) => handle_init(matches, config_file),
|
||||||
("info", Some(matches)) => {
|
Some(("info", matches)) => {
|
||||||
let local_info_only = matches.is_present("local_info_only");
|
let local_info_only = matches.is_present("local_info_only");
|
||||||
let eval = matches.is_present("eval");
|
let eval = matches.is_present("eval");
|
||||||
command::info(config_file, local_info_only, eval).map(|_| ())
|
command::info(config_file, local_info_only, eval).map(|_| ())
|
||||||
}
|
}
|
||||||
("deploy", Some(matches)) => {
|
Some(("deploy", matches)) => {
|
||||||
let from_keypair_file = matches.value_of("from_keypair_file").unwrap();
|
let from_keypair_file = matches.value_of("from_keypair_file").unwrap();
|
||||||
let json_rpc_url = matches.value_of("json_rpc_url").unwrap();
|
let json_rpc_url = matches.value_of("json_rpc_url").unwrap();
|
||||||
let download_url = matches.value_of("download_url").unwrap();
|
let download_url = matches.value_of("download_url").unwrap();
|
||||||
@@ -261,9 +260,9 @@ pub fn main() -> Result<(), String> {
|
|||||||
update_manifest_keypair_file,
|
update_manifest_keypair_file,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
("gc", Some(_matches)) => command::gc(config_file),
|
Some(("gc", _matches)) => command::gc(config_file),
|
||||||
("update", Some(_matches)) => command::update(config_file, false).map(|_| ()),
|
Some(("update", _matches)) => command::update(config_file, false).map(|_| ()),
|
||||||
("run", Some(matches)) => {
|
Some(("run", matches)) => {
|
||||||
let program_name = matches.value_of("program_name").unwrap();
|
let program_name = matches.value_of("program_name").unwrap();
|
||||||
let program_arguments = matches
|
let program_arguments = matches
|
||||||
.values_of("program_arguments")
|
.values_of("program_arguments")
|
||||||
@@ -279,12 +278,12 @@ pub fn main() -> Result<(), String> {
|
|||||||
pub fn main_init() -> Result<(), String> {
|
pub fn main_init() -> Result<(), String> {
|
||||||
solana_logger::setup();
|
solana_logger::setup();
|
||||||
|
|
||||||
let matches = App::new("solana-install-init")
|
let matches = Command::new("solana-install-init")
|
||||||
.about("Initializes a new installation")
|
.about("Initializes a new installation")
|
||||||
.version(solana_version::version!())
|
.version(solana_version::version!())
|
||||||
.arg({
|
.arg({
|
||||||
let arg = Arg::with_name("config_file")
|
let arg = Arg::new("config_file")
|
||||||
.short("c")
|
.short('c')
|
||||||
.long("config")
|
.long("config")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
@@ -295,8 +294,8 @@ pub fn main_init() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.arg({
|
.arg({
|
||||||
let arg = Arg::with_name("data_dir")
|
let arg = Arg::new("data_dir")
|
||||||
.short("d")
|
.short('d')
|
||||||
.long("data-dir")
|
.long("data-dir")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
@@ -308,35 +307,35 @@ pub fn main_init() -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("json_rpc_url")
|
Arg::new("json_rpc_url")
|
||||||
.short("u")
|
.short('u')
|
||||||
.long("url")
|
.long("url")
|
||||||
.value_name("URL")
|
.value_name("URL")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value(defaults::JSON_RPC_URL)
|
.default_value(defaults::JSON_RPC_URL)
|
||||||
.validator(is_url)
|
.validator(|s| is_url(s.to_string()))
|
||||||
.help("JSON RPC URL for the solana cluster"),
|
.help("JSON RPC URL for the solana cluster"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no_modify_path")
|
Arg::new("no_modify_path")
|
||||||
.long("no-modify-path")
|
.long("no-modify-path")
|
||||||
.help("Don't configure the PATH environment variable"),
|
.help("Don't configure the PATH environment variable"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("update_manifest_pubkey")
|
Arg::new("update_manifest_pubkey")
|
||||||
.short("p")
|
.short('p')
|
||||||
.long("pubkey")
|
.long("pubkey")
|
||||||
.value_name("PUBKEY")
|
.value_name("PUBKEY")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.validator(is_pubkey)
|
.validator(|s| is_pubkey(s.to_string()))
|
||||||
.help("Public key of the update manifest"),
|
.help("Public key of the update manifest"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("explicit_release")
|
Arg::new("explicit_release")
|
||||||
.value_name("release")
|
.value_name("release")
|
||||||
.index(1)
|
.index(1)
|
||||||
.conflicts_with_all(&["json_rpc_url", "update_manifest_pubkey"])
|
.conflicts_with_all(&["json_rpc_url", "update_manifest_pubkey"])
|
||||||
.validator(is_explicit_release)
|
.validator(|s| is_explicit_release(s.to_string()))
|
||||||
.help("The release version or channel to install"),
|
.help("The release version or channel to install"),
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
Reference in New Issue
Block a user