Commit c1fd9f0
authored
feat(bin): restructure
Refactor `katana init` command to use explicit subcommands for rollup and sovereign chain modes. Now running `katana init` requires you to select the mode as a subcommand: `katana init rollup` or `katana init sovereign`.
One of the reason why we made this change is because the CLI argument configurations will always require you to provide the arguments instead of falling back to prompting.
The expected behaviour when you literally just run `katana init` is for it to prompt the arguments like so:
<img width="411" height="51" alt="Screenshot 2025-09-23 at 10 03 49 AM" src="https://github.com/user-attachments/assets/e910a787-e412-4c61-b519-ea574d689382"
/>
But due to how the CLI arguments is being configured, we instead get an error for not providing the arguments using flags:
<img width="1030" height="149" alt="Screenshot 2025-09-23 at 10 04
05 AM"
src="https://github.com/user-attachments/assets/d5ab9ab6-ecb3-43f7-bd80-e4b9b646edfc"
/>
This is mainly because of the `#[arg(required_unless_present = "sovereign")]` tag we're using that forces us to provide the options if `--sovereign` is not present.
https://github.com/dojoengine/katana/blob/d584d4224f75f3648d55d1e4cec773ed638967ff/bin/katana/src/cli/init/mod.rs#L44-L48
Afaik it doesn't seem to be possible to 'fix' this using `clap` derive macro. Even if it does, I believe separating the mode into separate commands feels like a better UX.
## Comparison with current behaviour
- Current: `katana init --id my-chain --settlement-chain sepolia ...`
- New: `katana init rollup --id my-chain --settlement-chain sepolia ...`init command with explicit rollup/sovereign modes (#280)1 parent 291c572 commit c1fd9f0
File tree
5 files changed
+320
-150
lines changed- bin/katana/src
- cli
- init
5 files changed
+320
-150
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| |||
0 commit comments