Skip to content

Commit fcd5086

Browse files
committed
chore: sketching select API and environment necessity.
1 parent 5ad3cc0 commit fcd5086

File tree

8 files changed

+153
-52
lines changed

8 files changed

+153
-52
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ include-vendor = { git = "https://github.com/movementlabsxyz/kestrel.git", rev =
142142
ready-docker = { git = "https://github.com/movementlabsxyz/kestrel.git", rev = "3220d704df7e06d1dcc5266e15eaf05db86fdb07" }
143143

144144
# orfile
145-
orfile = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "b49cb42495816fa00a1107be5bbf41aff3a8255d" }
145+
orfile = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "c34c5927796c87e50a2e931760e3a226b5aa4ebf" }
146+
slect = { git = "https://github.com/movementlabsxyz/orfile.git", rev = "c34c5927796c87e50a2e931760e3a226b5aa4ebf" }
146147

147148
# docs
148149
clap-markdown-ext = { git = "https://github.com/movementlabsxyz/clap-markdown-ext.git", rev = "8f54fe424504bf37fb01dc69aaed8166e429fe6a" }

migration/cli/migrate-node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ futures = { workspace = true }
3232
sysinfo = { workspace = true }
3333
tracing = { workspace = true }
3434
tracing-subscriber = { workspace = true }
35+
slect = { workspace = true }
3536

3637
[lints]
3738
workspace = true

migration/cli/migrate-node/docs/cli/README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ This document contains the help content for the `mtma-migrate-node` command-line
1111
* [`mtma-migrate-node markdown print`](#mtma-migrate-node-markdown-print)
1212
* [`mtma-migrate-node markdown workspace`](#mtma-migrate-node-markdown-workspace)
1313
* [`mtma-migrate-node migrate`](#mtma-migrate-node-migrate)
14-
* [`mtma-migrate-node migrate where`](#mtma-migrate-node-migrate-where)
15-
* [`mtma-migrate-node migrate using`](#mtma-migrate-node-migrate-using)
14+
* [`mtma-migrate-node migrate core`](#mtma-migrate-node-migrate-core)
15+
* [`mtma-migrate-node migrate select`](#mtma-migrate-node-migrate-select)
1616

1717
## `mtma-migrate-node`
1818

@@ -94,16 +94,16 @@ Migrate from Movement to MovementAptos
9494

9595
###### **Subcommands:**
9696

97-
* `where`Run migrate with all parameters passed explicitly as CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
98-
* `using`Run migrate with parameters from environment variables, config files, and CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
97+
* `core`Core migration over the node
98+
* `select`Select migration over the node
9999

100100

101101

102-
## `mtma-migrate-node migrate where`
102+
## `mtma-migrate-node migrate core`
103103

104-
Run migrate with all parameters passed explicitly as CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
104+
Core migration over the node
105105

106-
**Usage:** `mtma-migrate-node migrate where --movement-state-db-path <MOVEMENT_STATE_DB_PATH> --movement-aptos-state-db-path <MOVEMENT_APTOS_STATE_DB_PATH>`
106+
**Usage:** `mtma-migrate-node migrate core --movement-state-db-path <MOVEMENT_STATE_DB_PATH> --movement-aptos-state-db-path <MOVEMENT_APTOS_STATE_DB_PATH>`
107107

108108
###### **Options:**
109109

@@ -112,19 +112,29 @@ Run migrate with all parameters passed explicitly as CLI flags. See Orfile docum
112112

113113

114114

115-
## `mtma-migrate-node migrate using`
115+
## `mtma-migrate-node migrate select`
116+
117+
Select migration over the node
118+
119+
**Usage:** `mtma-migrate-node migrate select [OPTIONS] [-- <EXTRA_ARGS>...]`
120+
121+
Selection (1/1): null
122+
The config for the migration
123+
124+
Usage: null{}
125+
126+
Options:
127+
-h, --help Print help (see more with '--help')
116128

117-
Run migrate with parameters from environment variables, config files, and CLI flags. See Orfile documentation for more details: <https://github.com/movementlabsxyz/orfile>
118129

119-
**Usage:** `mtma-migrate-node migrate using [OPTIONS] [EXTRA_ARGS]...`
120130

121131
###### **Arguments:**
122132

123-
* `<EXTRA_ARGS>` — Extra arguments to be passed to the CLI
133+
* `<EXTRA_ARGS>` — Extra arguments to be passed to subcommands
124134

125135
###### **Options:**
126136

127-
* `--config-path <CONFIG_PATH>`Path to the config file for migrate
137+
* `--null`Enable the #flag_names subcommand
128138

129139

130140

migration/cli/migrate-node/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub enum MtmaMigrateNodeSubcommand {
1919
Markdown(Markdown),
2020
/// Migrate from Movement to MovementAptos.
2121
#[clap(subcommand)]
22-
Migrate(migrate::or_file::Migrate),
22+
Migrate(migrate::Migrate),
2323
}
2424

2525
/// Implement the `From` trait for `MtmaMigrateNode` to convert it into a `MtmaMigrateNodeSubcommand`.
Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1+
pub mod core;
2+
pub mod select;
3+
14
use clap::Parser;
2-
use mtma_core::Config;
3-
use orfile::Orfile;
4-
use serde::{Deserialize, Serialize};
55

66
/// Migrates the node.
7-
#[derive(Parser, Serialize, Deserialize, Debug, Clone, Orfile)]
7+
#[derive(Parser, Debug)]
88
#[clap(help_expected = true)]
9-
pub struct Migrate {
10-
/// The core config to use.
11-
#[orfile(config)]
12-
#[clap(flatten)]
13-
pub config: Config,
9+
pub enum Migrate {
10+
/// Core migration over the node.
11+
Core(core::Core),
12+
/// Select migration over the node.
13+
Select(select::select::Select),
1414
}
1515

1616
impl Migrate {
1717
pub async fn execute(&self) -> Result<(), anyhow::Error> {
18-
let migrate = self.config.build()?;
19-
migrate.run().await?; // we unwrap the error as an easy way to do marshalling from [MigrateError] to [anyhow::Error]
20-
Ok(())
21-
}
22-
}
23-
24-
impl or_file::Migrate {
25-
pub async fn execute(&self) -> Result<(), anyhow::Error> {
26-
let inner = self.clone().resolve().await?;
27-
inner.execute().await
18+
match self {
19+
Migrate::Core(core) => core.execute().await,
20+
Migrate::Select(select) => select.execute().await,
21+
}
2822
}
2923
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use clap::Parser;
2+
use mtma_core::Config;
3+
use orfile::Orfile;
4+
use serde::{Deserialize, Serialize};
5+
6+
/// Core migration over the node.
7+
#[derive(Parser, Serialize, Deserialize, Debug, Clone, Orfile)]
8+
#[clap(help_expected = true)]
9+
pub struct Core {
10+
/// The core config to use.
11+
#[orfile(config)]
12+
#[clap(flatten)]
13+
pub config: Config,
14+
}
15+
16+
impl Core {
17+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
18+
let migrate = self.config.build()?;
19+
migrate.run().await?; // we unwrap the error as an easy way to do marshalling from [CoreError] to [anyhow::Error]
20+
Ok(())
21+
}
22+
}
23+
24+
impl or_file::Core {
25+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
26+
let inner = self.clone().resolve().await?;
27+
inner.execute().await
28+
}
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use clap::Parser;
2+
use mtma_node_null_core::Config as NullConfig;
3+
use serde::{Deserialize, Serialize};
4+
use slect::Slect;
5+
6+
/// Select migration over the node.
7+
#[derive(Parser, Slect, Deserialize, Serialize, Debug, Clone)]
8+
#[clap(help_expected = true)]
9+
pub struct Select {
10+
/// Extra args to pass to slect API
11+
#[slect(null = NullConfig)]
12+
extra_args: Vec<String>,
13+
}
14+
15+
impl select::Select {
16+
pub async fn execute(&self) -> Result<(), anyhow::Error> {
17+
let maybe_null = self.select().map_err(|e| anyhow::anyhow!("{}", e))?;
18+
19+
if let Some(null) = maybe_null {
20+
let _build = null.build()?;
21+
22+
// needs an environment for the node to run.
23+
// How we load this environment is in process of being abstraced.
24+
}
25+
26+
Ok(())
27+
}
28+
}

0 commit comments

Comments
 (0)