Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 43ee8a3

Browse files
authored
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
1 parent d1012cd commit 43ee8a3

File tree

10 files changed

+68
-85
lines changed

10 files changed

+68
-85
lines changed

Cargo.lock

Lines changed: 37 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/node/cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ hex-literal = "0.2.1"
3131
jsonrpc-core = "14.0.3"
3232
log = "0.4.8"
3333
rand = "0.7.2"
34-
structopt = "0.3.3"
34+
structopt = "=0.3.7"
3535

3636
# primitives
3737
sp-authority-discovery = { version = "2.0.0", path = "../../../primitives/authority-discovery" }
@@ -107,7 +107,7 @@ tempfile = "3.1.0"
107107
[build-dependencies]
108108
sc-cli = { version = "2.0.0", package = "sc-cli", path = "../../../client/cli" }
109109
build-script-utils = { version = "2.0.0", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" }
110-
structopt = "0.3.3"
110+
structopt = "=0.3.7"
111111
vergen = "3.0.4"
112112

113113
[features]

bin/node/cli/src/cli.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
2020
use sc_cli::{IntoExit, NoCustom, SharedParams, ImportParams, error};
2121
use sc_service::{AbstractService, Roles as ServiceRoles, Configuration};
2222
use log::info;
23-
use structopt::{StructOpt, clap::App};
24-
use sc_cli::{display_role, parse_and_prepare, AugmentClap, GetSharedParams, ParseAndPrepare};
23+
use structopt::StructOpt;
24+
use sc_cli::{display_role, parse_and_prepare, GetSharedParams, ParseAndPrepare};
2525
use crate::{service, ChainSpec, load_spec};
2626
use crate::factory_impl::FactoryState;
2727
use node_transaction_factory::RuntimeAdapter;
@@ -88,12 +88,6 @@ pub struct FactoryCmd {
8888
pub import_params: ImportParams,
8989
}
9090

91-
impl AugmentClap for FactoryCmd {
92-
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
93-
FactoryCmd::augment_clap(app)
94-
}
95-
}
96-
9791
/// Parse command line arguments into service configuration.
9892
pub fn run<I, T, E>(args: I, exit: E, version: sc_cli::VersionInfo) -> error::Result<()> where
9993
I: IntoIterator<Item = T>,

bin/utils/chain-spec-builder/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ sc-keystore = { version = "2.0.0", path = "../../../client/keystore" }
1111
node-cli = { version = "2.0.0", path = "../../node/cli" }
1212
sp-core = { version = "2.0.0", path = "../../../primitives/core" }
1313
rand = "0.7.2"
14-
structopt = "0.3.3"
14+
structopt = "=0.3.7"

client/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine"
3131
sc-telemetry = { version = "2.0.0", path = "../telemetry" }
3232
sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" }
3333
names = "0.11.0"
34-
structopt = "0.3.3"
34+
structopt = "=0.3.7"
3535
sc-tracing = { version = "2.0.0", path = "../tracing" }
3636

3737
[target.'cfg(not(target_os = "unknown"))'.dependencies]

client/cli/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ use std::{
4848

4949
use names::{Generator, Name};
5050
use regex::Regex;
51-
use structopt::{StructOpt, clap::AppSettings};
51+
use structopt::{StructOpt, StructOptInternal, clap::AppSettings};
5252
#[doc(hidden)]
5353
pub use structopt::clap::App;
5454
use params::{
@@ -57,7 +57,7 @@ use params::{
5757
NodeKeyParams, NodeKeyType, Cors, CheckBlockCmd,
5858
};
5959
pub use params::{NoCustom, CoreParams, SharedParams, ImportParams, ExecutionStrategy};
60-
pub use traits::{GetSharedParams, AugmentClap};
60+
pub use traits::GetSharedParams;
6161
use app_dirs::{AppInfo, AppDataType};
6262
use log::info;
6363
use lazy_static::lazy_static;
@@ -196,7 +196,7 @@ pub fn parse_and_prepare<'a, CC, RP, I>(
196196
) -> ParseAndPrepare<'a, CC, RP>
197197
where
198198
CC: StructOpt + Clone + GetSharedParams,
199-
RP: StructOpt + Clone + AugmentClap,
199+
RP: StructOpt + Clone + StructOptInternal,
200200
I: IntoIterator,
201201
<I as IntoIterator>::Item: Into<std::ffi::OsString> + Clone,
202202
{

client/cli/src/params.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use crate::traits::{AugmentClap, GetSharedParams};
17+
use crate::traits::GetSharedParams;
1818

1919
use std::{str::FromStr, path::PathBuf};
20-
use structopt::{StructOpt, clap::{arg_enum, App, AppSettings, SubCommand, Arg}};
20+
use structopt::{StructOpt, StructOptInternal, clap::{arg_enum, App, AppSettings, SubCommand, Arg}};
2121

2222
pub use crate::execution_strategy::ExecutionStrategy;
2323

@@ -208,7 +208,7 @@ pub struct NetworkConfigurationParams {
208208

209209
#[allow(missing_docs)]
210210
#[structopt(flatten)]
211-
pub node_key_params: NodeKeyParams
211+
pub node_key_params: NodeKeyParams,
212212
}
213213

214214
arg_enum! {
@@ -278,7 +278,7 @@ pub struct NodeKeyParams {
278278
/// If the file does not exist, it is created with a newly generated secret key of
279279
/// the chosen type.
280280
#[structopt(long = "node-key-file", value_name = "FILE")]
281-
pub node_key_file: Option<PathBuf>
281+
pub node_key_file: Option<PathBuf>,
282282
}
283283

284284
/// Parameters used to create the pool configuration.
@@ -623,14 +623,14 @@ impl StructOpt for Keyring {
623623
unimplemented!("Should not be called for `TestAccounts`.")
624624
}
625625

626-
fn from_clap(m: &::structopt::clap::ArgMatches) -> Self {
626+
fn from_clap(m: &structopt::clap::ArgMatches) -> Self {
627627
Keyring {
628628
account: TEST_ACCOUNTS_CLI_VALUES.iter().find(|a| m.is_present(&a.name)).map(|a| a.variant),
629629
}
630630
}
631631
}
632632

633-
impl AugmentClap for Keyring {
633+
impl StructOptInternal for Keyring {
634634
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
635635
TEST_ACCOUNTS_CLI_VALUES.iter().fold(app, |app, a| {
636636
let conflicts_with_strs = a.conflicts_with.iter().map(|s| s.as_str()).collect::<Vec<_>>();
@@ -646,12 +646,6 @@ impl AugmentClap for Keyring {
646646
}
647647
}
648648

649-
impl Keyring {
650-
fn is_subcommand() -> bool {
651-
false
652-
}
653-
}
654-
655649
/// Default to verbosity level 0, if none is provided.
656650
fn parse_telemetry_endpoints(s: &str) -> Result<(String, u8), Box<dyn std::error::Error>> {
657651
let pos = s.find(' ');
@@ -705,8 +699,6 @@ fn parse_cors(s: &str) -> Result<Cors, Box<dyn std::error::Error>> {
705699
Ok(if is_all { Cors::All } else { Cors::List(origins) })
706700
}
707701

708-
impl_augment_clap!(RunCmd);
709-
710702
/// The `build-spec` command used to build a specification.
711703
#[derive(Debug, StructOpt, Clone)]
712704
pub struct BuildSpecCmd {
@@ -895,7 +887,7 @@ pub enum CoreParams<CC, RP> {
895887

896888
impl<CC, RP> StructOpt for CoreParams<CC, RP> where
897889
CC: StructOpt + GetSharedParams,
898-
RP: StructOpt + AugmentClap
890+
RP: StructOpt + StructOptInternal,
899891
{
900892
fn clap<'a, 'b>() -> App<'a, 'b> {
901893
RP::augment_clap(
@@ -964,7 +956,7 @@ impl StructOpt for NoCustom {
964956
}
965957
}
966958

967-
impl AugmentClap for NoCustom {
959+
impl StructOptInternal for NoCustom {
968960
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
969961
app
970962
}
@@ -985,7 +977,7 @@ pub struct MergeParameters<L, R> {
985977
pub right: R,
986978
}
987979

988-
impl<L, R> StructOpt for MergeParameters<L, R> where L: StructOpt + AugmentClap, R: StructOpt {
980+
impl<L, R> StructOpt for MergeParameters<L, R> where L: StructOpt + StructOptInternal, R: StructOpt {
989981
fn clap<'a, 'b>() -> App<'a, 'b> {
990982
L::augment_clap(R::clap())
991983
}

client/cli/src/traits.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,8 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
1616

17-
use structopt::{StructOpt, clap::App};
1817
use crate::params::SharedParams;
1918

20-
/// Something that can augment a clap app with further parameters.
21-
/// `derive(StructOpt)` is implementing this function by default, so a macro `impl_augment_clap!`
22-
/// is provided to simplify the implementation of this trait.
23-
pub trait AugmentClap: StructOpt {
24-
/// Augment the given clap `App` with further parameters.
25-
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b>;
26-
}
27-
28-
/// Macro for implementing the `AugmentClap` trait.
29-
/// This requires that the given type uses `derive(StructOpt)`!
30-
#[macro_export]
31-
macro_rules! impl_augment_clap {
32-
( $type:ident ) => {
33-
impl $crate::AugmentClap for $type {
34-
fn augment_clap<'a, 'b>(app: $crate::App<'a, 'b>) -> $crate::App<'a, 'b> {
35-
$type::augment_clap(app)
36-
}
37-
}
38-
}
39-
}
40-
4119
/// Supports getting common params.
4220
pub trait GetSharedParams {
4321
/// Returns shared params if any.

frame/indices/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ sp-core = { version = "2.0.0", default-features = false, path = "../../primitive
1616
frame-support = { version = "2.0.0", default-features = false, path = "../support" }
1717
frame-system = { version = "2.0.0", default-features = false, path = "../system" }
1818

19-
[dev-dependencies]
20-
ref_thread_local = "0.0.0"
21-
2219
[features]
2320
default = ["std"]
2421
std = [

0 commit comments

Comments
 (0)