-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): split sub-command
run
to init
and run
- Loading branch information
1 parent
c86f065
commit a4221eb
Showing
9 changed files
with
144 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use clap::Parser; | ||
|
||
use common_config_parser::types::{spec::ChainSpec, Config}; | ||
use common_version::Version; | ||
|
||
use crate::{ | ||
error::{Error, Result}, | ||
utils, | ||
}; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(about = "Initialize new axon data directory")] | ||
pub struct InitArgs { | ||
#[arg( | ||
short = 'c', | ||
long = "config", | ||
value_name = "CONFIG_FILE", | ||
help = "File path of client configurations." | ||
)] | ||
pub config: Config, | ||
#[arg( | ||
short = 's', | ||
long = "chain-spec", | ||
value_name = "CHAIN_SPEC_FILE", | ||
help = "File path of chain spec." | ||
)] | ||
pub spec: ChainSpec, | ||
} | ||
|
||
impl InitArgs { | ||
pub(crate) fn execute(self, kernel_version: Version) -> Result<()> { | ||
let Self { config, spec } = self; | ||
let genesis = spec.genesis.build_rich_block(); | ||
|
||
utils::check_version( | ||
&config.data_path_for_version(), | ||
&kernel_version, | ||
utils::latest_compatible_version(), | ||
)?; | ||
utils::register_log(&config); | ||
|
||
core_run::init(config, spec, genesis).map_err(Error::Running) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub(crate) mod init; | ||
pub(crate) mod run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.