Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 37 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ hex-literal = "0.2.1"
jsonrpc-core = "14.0.3"
log = "0.4.8"
rand = "0.7.2"
structopt = "0.3.3"
structopt = "=0.3.7"

# primitives
sp-authority-discovery = { version = "2.0.0", path = "../../../primitives/authority-discovery" }
Expand Down Expand Up @@ -107,7 +107,7 @@ tempfile = "3.1.0"
[build-dependencies]
sc-cli = { version = "2.0.0", package = "sc-cli", path = "../../../client/cli" }
build-script-utils = { version = "2.0.0", package = "substrate-build-script-utils", path = "../../../utils/build-script-utils" }
structopt = "0.3.3"
structopt = "=0.3.7"
vergen = "3.0.4"

[features]
Expand Down
10 changes: 2 additions & 8 deletions bin/node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use tokio::runtime::{Builder as RuntimeBuilder, Runtime};
use sc_cli::{IntoExit, NoCustom, SharedParams, ImportParams, error};
use sc_service::{AbstractService, Roles as ServiceRoles, Configuration};
use log::info;
use structopt::{StructOpt, clap::App};
use sc_cli::{display_role, parse_and_prepare, AugmentClap, GetSharedParams, ParseAndPrepare};
use structopt::StructOpt;
use sc_cli::{display_role, parse_and_prepare, GetSharedParams, ParseAndPrepare};
use crate::{service, ChainSpec, load_spec};
use crate::factory_impl::FactoryState;
use node_transaction_factory::RuntimeAdapter;
Expand Down Expand Up @@ -88,12 +88,6 @@ pub struct FactoryCmd {
pub import_params: ImportParams,
}

impl AugmentClap for FactoryCmd {
fn augment_clap<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> {
FactoryCmd::augment_clap(app)
}
}

/// Parse command line arguments into service configuration.
pub fn run<I, T, E>(args: I, exit: E, version: sc_cli::VersionInfo) -> error::Result<()> where
I: IntoIterator<Item = T>,
Expand Down
2 changes: 1 addition & 1 deletion bin/utils/chain-spec-builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ sc-keystore = { version = "2.0.0", path = "../../../client/keystore" }
node-cli = { version = "2.0.0", path = "../../node/cli" }
sp-core = { version = "2.0.0", path = "../../../primitives/core" }
rand = "0.7.2"
structopt = "0.3.3"
structopt = "=0.3.7"
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sp-state-machine = { version = "2.0.0", path = "../../primitives/state-machine"
sc-telemetry = { version = "2.0.0", path = "../telemetry" }
sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" }
names = "0.11.0"
structopt = "0.3.3"
structopt = "=0.3.7"
sc-tracing = { version = "2.0.0", path = "../tracing" }

[target.'cfg(not(target_os = "unknown"))'.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions client/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down Expand Up @@ -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,
{
Expand Down
26 changes: 9 additions & 17 deletions client/cli/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -208,7 +208,7 @@ pub struct NetworkConfigurationParams {

#[allow(missing_docs)]
#[structopt(flatten)]
pub node_key_params: NodeKeyParams
pub node_key_params: NodeKeyParams,
}

arg_enum! {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<_>>();
Expand All @@ -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(' ');
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
}
Expand All @@ -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())
}
Expand Down
22 changes: 0 additions & 22 deletions client/cli/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions frame/indices/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ sp-core = { version = "2.0.0", default-features = false, path = "../../primitive
frame-support = { version = "2.0.0", default-features = false, path = "../support" }
frame-system = { version = "2.0.0", default-features = false, path = "../system" }

[dev-dependencies]
ref_thread_local = "0.0.0"

[features]
default = ["std"]
std = [
Expand Down
Loading