pub fn parse_and_execute<'a, F, CC, RP, S, RS, E, I, T>(
	spec_factory: S,
	version: &VersionInfo,
	impl_name: &'static str,
	args: I,
	exit: E,
	run_service: RS,
) -> error::Result<Option<CC>>
where
	F: ServiceFactory,
	S: FnOnce(&str) -> Result<Option<ChainSpec<FactoryGenesis<F>>>, String>,
	CC: StructOpt + Clone + GetLogFilter,
	RP: StructOpt + Clone + AugmentClap,
	E: IntoExit,
	RS: FnOnce(E, RP, FactoryFullConfiguration<F>) -> Result<(), String>,
	I: IntoIterator<Item = T>,
	T: Into<std::ffi::OsString> + Clone,
{
	panic_handler::set(version.support_url);

	let full_version = service::config::full_version_from_strs(
		version.version,
		version.commit
	);

	let matches = CoreParams::<CC, RP>::clap()
		.name(version.executable_name)
		.author(version.author)
		.about(version.description)
		.version(&(full_version + "\n")[..])
		.setting(AppSettings::GlobalVersion)
		.setting(AppSettings::ArgsNegateSubcommands)
		.setting(AppSettings::SubcommandsNegateReqs)
		.get_matches_from(args);
	let cli_args = CoreParams::<CC, RP>::from_clap(&matches);

	let _ = init_logger(cli_args.get_log_filter().as_ref().map(|v| v.as_ref()).unwrap_or(""));
	fdlimit::raise_fd_limit();

	match cli_args {
		params::CoreParams::Run(params) => run_node::<F, _, _, _, _>(
			params, spec_factory, exit, run_service, impl_name, version,
		).map(|_| None),
		params::CoreParams::BuildSpec(params) =>
			build_spec::<F, _>(params, spec_factory, version).map(|_| None),
		params::CoreParams::ExportBlocks(params) =>
			export_blocks::<F, _, _>(params, spec_factory, exit, version).map(|_| None),
		params::CoreParams::ImportBlocks(params) =>
			import_blocks::<F, _, _>(params, spec_factory, exit, version).map(|_| None),
		params::CoreParams::PurgeChain(params) =>
			purge_chain::<F, _>(params, spec_factory, version).map(|_| None),
		params::CoreParams::Revert(params) =>
			revert_chain::<F, _>(params, spec_factory, version).map(|_| None),
		params::CoreParams::Custom(params) => Ok(Some(params)),
	}
}
/// Parse command line interface arguments and executes the desired command.
///
/// # Return value
///
/// A result that indicates if any error occurred.
/// If no error occurred and a custom subcommand was found, the subcommand is returned.
/// The user needs to handle this subcommand on its own.
///
/// # Remarks
///
/// `CC` is a custom subcommand. This needs to be an `enum`! If no custom subcommand is required,
/// `NoCustom` can be used as type here.
/// `RP` is are custom parameters for the run command. This needs to be a `struct`! The custom
/// parameters are visible to the user as if they were normal run command parameters. If no custom
/// parameters are required, `NoCustom` can be used as type here.
Parse command line interface arguments and executes the desired command.
Parse command line interface arguments and executes the desired command .
pub fn parse_and_execute<'a, F, CC, RP, S, RS, E, I, T>(
	spec_factory: S,
	version: &VersionInfo,
	impl_name: &'static str,
	args: I,
	exit: E,
	run_service: RS,
) -> error::Result<Option<CC>>
where
	F: ServiceFactory,
	S: FnOnce(&str) -> Result<Option<ChainSpec<FactoryGenesis<F>>>, String>,
	CC: StructOpt + Clone + GetLogFilter,
	RP: StructOpt + Clone + AugmentClap,
	E: IntoExit,
	RS: FnOnce(E, RP, FactoryFullConfiguration<F>) -> Result<(), String>,
	I: IntoIterator<Item = T>,
	T: Into<std::ffi::OsString> + Clone,
{
	panic_handler::set(version.support_url);
	let full_version = service::config::full_version_from_strs(
		version.version,
		version.commit
	);
	let matches = CoreParams::<CC, RP>::clap()
		.name(version.executable_name)
		.author(version.author)
		.about(version.description)
		.version(&(full_version + "\n")[..])
		.setting(AppSettings::GlobalVersion)
		.setting(AppSettings::ArgsNegateSubcommands)
		.setting(AppSettings::SubcommandsNegateReqs)
		.get_matches_from(args);
	let cli_args = CoreParams::<CC, RP>::from_clap(&matches);
	let _ = init_logger(cli_args.get_log_filter().as_ref().map(|v| v.as_ref()).unwrap_or(""));
	fdlimit::raise_fd_limit();
	match cli_args {
		params::CoreParams::Run(params) => run_node::<F, _, _, _, _>(
			params, spec_factory, exit, run_service, impl_name, version,
		).map(|_| None),
		params::CoreParams::BuildSpec(params) =>
			build_spec::<F, _>(params, spec_factory, version).map(|_| None),
		params::CoreParams::ExportBlocks(params) =>
			export_blocks::<F, _, _>(params, spec_factory, exit, version).map(|_| None),
		params::CoreParams::ImportBlocks(params) =>
			import_blocks::<F, _, _>(params, spec_factory, exit, version).map(|_| None),
		params::CoreParams::PurgeChain(params) =>
			purge_chain::<F, _>(params, spec_factory, version).map(|_| None),
		params::CoreParams::Revert(params) =>
			revert_chain::<F, _>(params, spec_factory, version).map(|_| None),
		params::CoreParams::Custom(params) => Ok(Some(params)),
	}
}
pub fn parse_and_execute < ' a , F , CC , RP , S , RS , E , I , T > ( spec_factory : S , version : & VersionInfo , impl_name : & ' static str , args : I , exit : E , run_service : RS , ) -> error :: Result < Option < CC > > where F : ServiceFactory , S : FnOnce ( & str ) -> Result < Option < ChainSpec < FactoryGenesis < F > > > , String > , CC : StructOpt + Clone + GetLogFilter , RP : StructOpt + Clone + AugmentClap , E : IntoExit , RS : FnOnce ( E , RP , FactoryFullConfiguration < F > ) -> Result < ( ) , String > , I : IntoIterator < Item = T > , T : Into < std :: ffi :: OsString > + Clone , { panic_handler :: set ( version . support_url ) ; let full_version = service :: config :: full_version_from_strs ( version . version , version . commit ) ; let matches = CoreParams :: < CC , RP > :: clap ( ) . name ( version . executable_name ) . author ( version . author ) . about ( version . description ) . version ( & ( full_version + " \n " ) [ .. ] ) . setting ( AppSettings :: GlobalVersion ) . setting ( AppSettings :: ArgsNegateSubcommands ) . setting ( AppSettings :: SubcommandsNegateReqs ) . get_matches_from ( args ) ; let cli_args = CoreParams :: < CC , RP > :: from_clap ( & matches ) ; let _ = init_logger ( cli_args . get_log_filter ( ) . as_ref ( ) . map ( | v | v . as_ref ( ) ) . unwrap_or ( " " ) ) ; fdlimit :: raise_fd_limit ( ) ; match cli_args { params :: CoreParams :: Run ( params ) => run_node :: < F , _ , _ , _ , _ > ( params , spec_factory , exit , run_service , impl_name , version , ) . map ( | _ | None ) , params :: CoreParams :: BuildSpec ( params ) => build_spec :: < F , _ > ( params , spec_factory , version ) . map ( | _ | None ) , params :: CoreParams :: ExportBlocks ( params ) => export_blocks :: < F , _ , _ > ( params , spec_factory , exit , version ) . map ( | _ | None ) , params :: CoreParams :: ImportBlocks ( params ) => import_blocks :: < F , _ , _ > ( params , spec_factory , exit , version ) . map ( | _ | None ) , params :: CoreParams :: PurgeChain ( params ) => purge_chain :: < F , _ > ( params , spec_factory , version ) . map ( | _ | None ) , params :: CoreParams :: Revert ( params ) => revert_chain :: < F , _ > ( params , spec_factory , version ) . map ( | _ | None ) , params :: CoreParams :: Custom ( params ) => Ok ( Some ( params ) ) , } }
Parse command line interface arguments and executes the desired command.
Parse command line interface arguments and executes the desired command .
spec_factory
S
version
&VersionInfo
impl_name
&'static str
args
I
exit
E
run_service
RS
spec_factory
S
version
&VersionInfo
impl_name
&'static str
args
I
exit
E
run_service
RS
return value
A result that indicates if any error occurred.
If no error occurred and a custom subcommand was found, the subcommand is returned.
The user needs to handle this subcommand on its own.
A result that indicates if any error occurred . If no error occurred and a custom subcommand was found the subcommand is returned . The user needs to handle this subcommand on its own .
remarks
`CC` is a custom subcommand. This needs to be an `enum`. If no custom subcommand is required,
`NoCustom` can be used as type here.
`RP` is are custom parameters for the run command. This needs to be a `struct`. The custom
parameters are visible to the user as if they were normal run command parameters. If no custom
parameters are required, `NoCustom` can be used as type here.
` CC ` is a custom subcommand . This needs to be an ` enum ` . If no custom subcommand is required ` NoCustom ` can be used as type here . ` RP ` is are custom parameters for the run command . This needs to be a ` struct ` . The custom parameters are visible to the user as if they were normal run command parameters . If no custom parameters are required ` NoCustom ` can be used as type here .