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:
Bastian Köcher
2019-12-28 22:52:18 +01:00
committed by GitHub
parent 9876d3dd09
commit 56355879be
10 changed files with 68 additions and 85 deletions
+9 -17
View File
@@ -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())
}