mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 21:11:07 +00:00
Fix cli for structopt 0.3.7 and pin to that version (#4509)
* Fix cli for structopt 0.3.7 and pin to that version This is just some hotfix to make everything compile. In the future it will require another pr to not depend on internals of StructOpt, but that will probably also require some additions to StructOpt itself. To not break the code again with another StructOpt, this also pins the StructOpt version. * Fix benches * Fix for fix
This commit is contained in:
@@ -48,7 +48,7 @@ use std::{
|
||||
|
||||
use names::{Generator, Name};
|
||||
use regex::Regex;
|
||||
use structopt::{StructOpt, clap::AppSettings};
|
||||
use structopt::{StructOpt, StructOptInternal, clap::AppSettings};
|
||||
#[doc(hidden)]
|
||||
pub use structopt::clap::App;
|
||||
use params::{
|
||||
@@ -57,7 +57,7 @@ use params::{
|
||||
NodeKeyParams, NodeKeyType, Cors, CheckBlockCmd,
|
||||
};
|
||||
pub use params::{NoCustom, CoreParams, SharedParams, ImportParams, ExecutionStrategy};
|
||||
pub use traits::{GetSharedParams, AugmentClap};
|
||||
pub use traits::GetSharedParams;
|
||||
use app_dirs::{AppInfo, AppDataType};
|
||||
use log::info;
|
||||
use lazy_static::lazy_static;
|
||||
@@ -196,7 +196,7 @@ pub fn parse_and_prepare<'a, CC, RP, I>(
|
||||
) -> ParseAndPrepare<'a, CC, RP>
|
||||
where
|
||||
CC: StructOpt + Clone + GetSharedParams,
|
||||
RP: StructOpt + Clone + AugmentClap,
|
||||
RP: StructOpt + Clone + StructOptInternal,
|
||||
I: IntoIterator,
|
||||
<I as IntoIterator>::Item: Into<std::ffi::OsString> + Clone,
|
||||
{
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::traits::{AugmentClap, GetSharedParams};
|
||||
use crate::traits::GetSharedParams;
|
||||
|
||||
use std::{str::FromStr, path::PathBuf};
|
||||
use structopt::{StructOpt, clap::{arg_enum, App, AppSettings, SubCommand, Arg}};
|
||||
use structopt::{StructOpt, StructOptInternal, clap::{arg_enum, App, AppSettings, SubCommand, Arg}};
|
||||
|
||||
pub use crate::execution_strategy::ExecutionStrategy;
|
||||
|
||||
@@ -208,7 +208,7 @@ pub struct NetworkConfigurationParams {
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub node_key_params: NodeKeyParams
|
||||
pub node_key_params: NodeKeyParams,
|
||||
}
|
||||
|
||||
arg_enum! {
|
||||
@@ -278,7 +278,7 @@ pub struct NodeKeyParams {
|
||||
/// If the file does not exist, it is created with a newly generated secret key of
|
||||
/// the chosen type.
|
||||
#[structopt(long = "node-key-file", value_name = "FILE")]
|
||||
pub node_key_file: Option<PathBuf>
|
||||
pub node_key_file: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// Parameters used to create the pool configuration.
|
||||
@@ -623,14 +623,14 @@ impl StructOpt for Keyring {
|
||||
unimplemented!("Should not be called for `TestAccounts`.")
|
||||
}
|
||||
|
||||
fn from_clap(m: &::structopt::clap::ArgMatches) -> Self {
|
||||
fn from_clap(m: &structopt::clap::ArgMatches) -> Self {
|
||||
Keyring {
|
||||
account: TEST_ACCOUNTS_CLI_VALUES.iter().find(|a| m.is_present(&a.name)).map(|a| a.variant),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AugmentClap for Keyring {
|
||||
impl StructOptInternal for Keyring {
|
||||
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
|
||||
TEST_ACCOUNTS_CLI_VALUES.iter().fold(app, |app, a| {
|
||||
let conflicts_with_strs = a.conflicts_with.iter().map(|s| s.as_str()).collect::<Vec<_>>();
|
||||
@@ -646,12 +646,6 @@ impl AugmentClap for Keyring {
|
||||
}
|
||||
}
|
||||
|
||||
impl Keyring {
|
||||
fn is_subcommand() -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Default to verbosity level 0, if none is provided.
|
||||
fn parse_telemetry_endpoints(s: &str) -> Result<(String, u8), Box<dyn std::error::Error>> {
|
||||
let pos = s.find(' ');
|
||||
@@ -705,8 +699,6 @@ fn parse_cors(s: &str) -> Result<Cors, Box<dyn std::error::Error>> {
|
||||
Ok(if is_all { Cors::All } else { Cors::List(origins) })
|
||||
}
|
||||
|
||||
impl_augment_clap!(RunCmd);
|
||||
|
||||
/// The `build-spec` command used to build a specification.
|
||||
#[derive(Debug, StructOpt, Clone)]
|
||||
pub struct BuildSpecCmd {
|
||||
@@ -895,7 +887,7 @@ pub enum CoreParams<CC, RP> {
|
||||
|
||||
impl<CC, RP> StructOpt for CoreParams<CC, RP> where
|
||||
CC: StructOpt + GetSharedParams,
|
||||
RP: StructOpt + AugmentClap
|
||||
RP: StructOpt + StructOptInternal,
|
||||
{
|
||||
fn clap<'a, 'b>() -> App<'a, 'b> {
|
||||
RP::augment_clap(
|
||||
@@ -964,7 +956,7 @@ impl StructOpt for NoCustom {
|
||||
}
|
||||
}
|
||||
|
||||
impl AugmentClap for NoCustom {
|
||||
impl StructOptInternal for NoCustom {
|
||||
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
|
||||
app
|
||||
}
|
||||
@@ -985,7 +977,7 @@ pub struct MergeParameters<L, R> {
|
||||
pub right: R,
|
||||
}
|
||||
|
||||
impl<L, R> StructOpt for MergeParameters<L, R> where L: StructOpt + AugmentClap, R: StructOpt {
|
||||
impl<L, R> StructOpt for MergeParameters<L, R> where L: StructOpt + StructOptInternal, R: StructOpt {
|
||||
fn clap<'a, 'b>() -> App<'a, 'b> {
|
||||
L::augment_clap(R::clap())
|
||||
}
|
||||
|
||||
@@ -14,30 +14,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use structopt::{StructOpt, clap::App};
|
||||
use crate::params::SharedParams;
|
||||
|
||||
/// Something that can augment a clap app with further parameters.
|
||||
/// `derive(StructOpt)` is implementing this function by default, so a macro `impl_augment_clap!`
|
||||
/// is provided to simplify the implementation of this trait.
|
||||
pub trait AugmentClap: StructOpt {
|
||||
/// Augment the given clap `App` with further parameters.
|
||||
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b>;
|
||||
}
|
||||
|
||||
/// Macro for implementing the `AugmentClap` trait.
|
||||
/// This requires that the given type uses `derive(StructOpt)`!
|
||||
#[macro_export]
|
||||
macro_rules! impl_augment_clap {
|
||||
( $type:ident ) => {
|
||||
impl $crate::AugmentClap for $type {
|
||||
fn augment_clap<'a, 'b>(app: $crate::App<'a, 'b>) -> $crate::App<'a, 'b> {
|
||||
$type::augment_clap(app)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Supports getting common params.
|
||||
pub trait GetSharedParams {
|
||||
/// Returns shared params if any.
|
||||
|
||||
Reference in New Issue
Block a user