[−]Trait polymesh::command::SubstrateCli
Substrate client CLI
This trait needs to be defined on the root structopt of the application. It will provide the implementation name, version, executable name, description, author, support_url, copyright start year and most importantly: how to load the chain spec.
StructOpt must not be in scope to use from_args (or the similar methods). This trait provides its own implementation that will fill the necessary field based on the trait's functions.
Required methods
pub fn impl_name() -> String
Implementation name.
pub fn impl_version() -> String
Implementation version.
By default this will look like this: 2.0.0-b950f731c-x86_64-linux-gnu where the hash is the short commit hash of the commit of in the Git repository.
pub fn description() -> String
Executable file description.
pub fn author() -> String
Executable file author.
pub fn support_url() -> String
Support URL.
pub fn copyright_start_year() -> i32
Copyright starting year (x-current year)
pub fn load_spec(
&self,
id: &str
) -> Result<Box<dyn ChainSpec + 'static, Global>, String>
&self,
id: &str
) -> Result<Box<dyn ChainSpec + 'static, Global>, String>
Chain spec factory
pub fn native_runtime_version(
chain_spec: &Box<dyn ChainSpec + 'static, Global>
) -> &'static RuntimeVersion
chain_spec: &Box<dyn ChainSpec + 'static, Global>
) -> &'static RuntimeVersion
Native runtime version.
Provided methods
pub fn executable_name() -> String
Executable file name.
Extracts the file name from std::env::current_exe()
.
Resorts to the env var CARGO_PKG_NAME
in case of Error.
pub fn from_args() -> Self where
Self: StructOpt,
Self: StructOpt,
Helper function used to parse the command line arguments. This is the equivalent of
structopt
's from_iter()
except that it takes a VersionInfo
argument to provide the name of
the application, author, "about" and version. It will also set AppSettings::GlobalVersion
.
To allow running the node without subcommand, tt also sets a few more settings:
AppSettings::ArgsNegateSubcommands
and AppSettings::SubcommandsNegateReqs
.
Gets the struct from the command line arguments. Print the error message and quit the program in case of failure.
pub fn from_iter<I>(iter: I) -> Self where
Self: StructOpt,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
Self: StructOpt,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
Helper function used to parse the command line arguments. This is the equivalent of
structopt
's from_iter()
except that it takes a VersionInfo
argument to provide the name of
the application, author, "about" and version. It will also set AppSettings::GlobalVersion
.
To allow running the node without subcommand, it also sets a few more settings:
AppSettings::ArgsNegateSubcommands
and AppSettings::SubcommandsNegateReqs
.
Gets the struct from any iterator such as a Vec
of your making.
Print the error message and quit the program in case of failure.
pub fn try_from_iter<I>(iter: I) -> Result<Self, Error> where
Self: StructOpt,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
Self: StructOpt,
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
Helper function used to parse the command line arguments. This is the equivalent of
structopt
's from_iter()
except that it takes a VersionInfo
argument to provide the name of
the application, author, "about" and version. It will also set AppSettings::GlobalVersion
.
To allow running the node without subcommand, it also sets a few more settings:
AppSettings::ArgsNegateSubcommands
and AppSettings::SubcommandsNegateReqs
.
Gets the struct from any iterator such as a Vec
of your making.
Print the error message and quit the program in case of failure.
NOTE: This method WILL NOT exit when --help
or --version
(or short versions) are
used. It will return a clap::Error
, where the clap::Error::kind
is a
clap::ErrorKind::HelpDisplayed
or clap::ErrorKind::VersionDisplayed
respectively.
You must call clap::Error::exit
or perform a std::process::exit
.
pub fn client_id() -> String
Returns the client ID: {impl_name}/v{impl_version}
pub fn create_configuration<T, DVC>(
&self,
command: &T,
task_executor: TaskExecutor
) -> Result<Configuration, Error> where
T: CliConfiguration<DVC>,
DVC: DefaultConfigurationValues,
&self,
command: &T,
task_executor: TaskExecutor
) -> Result<Configuration, Error> where
T: CliConfiguration<DVC>,
DVC: DefaultConfigurationValues,
Only create a Configuration for the command provided in argument
pub fn create_runner<T>(&self, command: &T) -> Result<Runner<Self>, Error> where
T: CliConfiguration<()>,
T: CliConfiguration<()>,
Create a runner for the command provided in argument. This will create a Configuration and a tokio runtime
Implementors
impl SubstrateCli for Cli
[src]
fn impl_name() -> String
[src]
fn impl_version() -> String
[src]
fn description() -> String
[src]
fn author() -> String
[src]
fn support_url() -> String
[src]
fn copyright_start_year() -> i32
[src]
fn executable_name() -> String
[src]
fn load_spec(&self, id: &str) -> Result<Box<dyn ChainSpec>, String>
[src]
fn native_runtime_version(
chain_spec: &Box<dyn ChainSpec>
) -> &'static RuntimeVersion
[src]
chain_spec: &Box<dyn ChainSpec>
) -> &'static RuntimeVersion