Skip to content

Commit 9d023b6

Browse files
authored
refactor: restructure CLI command hierarchy and remove slug parameter (#44)
* refactor: remove slug parameter from CLI, enforce title-first workflow - Remove slug parameter from CLI arguments (dot <slug>) - Remove slug from Create and RecipeCommands::New commands - Update handle_create to only accept title, auto-generate slug - Update non-interactive mode to require --title instead of slug - Update README to remove outdated CLI examples - Remove macOS Intel from README installation instructions - Enforce consistent title-first workflow across all interfaces This simplifies the CLI interface and ensures slugs are always auto-generated from titles, reducing user confusion and errors. * refactor: restructure CLI command hierarchy for scalability Make CLI future-proof by requiring explicit subcommands: Breaking changes: - Remove `dot` with no args (now requires subcommand) - Remove `dot create` command - Remove slug parameter entirely from CLI and SDK - Rename `dot recipe new` to `dot recipe create` Changes: - Make command field required (not optional) in Cli struct - Move all recipe creation arguments to global scope - Enforce title-first workflow (slug auto-generated) - Reserve top-level namespace for cross-cutting commands only Users must now use: - `dot recipe create` instead of `dot` or `dot create` - `--title` is required in non-interactive mode This change prepares the CLI for future non-recipe features while maintaining a clean, predictable command structure. * docs: update all documentation for new CLI command structure Update documentation to reflect the refactored command hierarchy: Changes: - Replace `dot` and `dot create` with `dot recipe create` - Replace slug parameters with --title flag - Update macOS binary names to user-friendly versions - Update command examples in all docs - Add comprehensive command list to architecture.md - Update non-interactive examples to require --title Files updated: - README.md: Updated CLI usage examples - CONTRIBUTING.md: Updated installation and command reference - cli/README.md: Complete rewrite of commands and examples - docs/architecture.md: Updated CLI commands section - docs/testing.md: Updated test recipe creation - core/VERSION_MANAGEMENT.md: Updated scaffolding example All documentation now accurately reflects the new command structure where `dot recipe create` is the canonical way to create recipes. * test: update CLI integration tests for new command structure Update all CLI integration tests to use the new command hierarchy: Changes: - Replace `dot <slug>` with `dot recipe create --title "..."` - Replace `dot create <slug>` with `dot recipe create --title "..."` - Update help text assertion (removed "Polkadot Cookbook") - Update error message assertions (slug → title) - Use valid titles that pass validation rules - Remove slug validation tests (no longer relevant) - Keep empty test placeholders for future title validation All 13 tests now pass with the new command structure. * ci: update SDK workflow for new CLI command structure Update test-sdk.yml to use the new CLI command hierarchy: Changes: - Rename "Test CLI - Valid slug" to "Test CLI - Valid recipe creation" - Update command: `dot test-ci-valid` → `dot recipe create --title "Testing CLI Validation"` - Rename "Test CLI - Invalid slug" to "Test CLI - Missing required title" - Update validation test to check for missing --title flag instead of invalid slug The workflow now tests the new command structure where recipe creation requires `dot recipe create --title "..."` instead of `dot <slug>`.
1 parent 059bd12 commit 9d023b6

File tree

9 files changed

+185
-262
lines changed

9 files changed

+185
-262
lines changed

.github/workflows/test-sdk.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,21 @@ jobs:
301301
if: needs.check-changes.outputs.sdk_changed == 'true'
302302
run: cargo build --package cli --verbose
303303

304-
- name: Test CLI - Valid slug
304+
- name: Test CLI - Valid recipe creation
305305
if: needs.check-changes.outputs.sdk_changed == 'true'
306306
run: |
307-
cargo run --package cli -- test-ci-valid --skip-install --no-git --non-interactive
308-
if [ ! -f "recipes/test-ci-valid/README.md" ]; then
307+
cargo run --package cli -- recipe create --title "Testing CLI Validation" --skip-install --no-git --non-interactive
308+
if [ ! -f "recipes/testing-cli-validation/README.md" ]; then
309309
echo "Error: Project was not created"
310310
exit 1
311311
fi
312-
rm -rf recipes/test-ci-valid
312+
rm -rf recipes/testing-cli-validation
313313
314-
- name: Test CLI - Invalid slug
314+
- name: Test CLI - Missing required title
315315
if: needs.check-changes.outputs.sdk_changed == 'true'
316316
run: |
317-
if cargo run --package cli -- Invalid-Slug --non-interactive 2>&1 | grep -q "Invalid recipe slug"; then
318-
echo "✓ Invalid slug error message found"
317+
if cargo run --package cli -- recipe create --non-interactive 2>&1 | grep -q "Title argument"; then
318+
echo "✓ Missing title error message found"
319319
exit 0
320320
else
321321
echo "✗ Expected error message not found"

CONTRIBUTING.md

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ Thank you for your interest in contributing! The easiest way to contribute a rec
2929
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-linux-amd64.tar.gz | tar xz
3030
sudo mv dot /usr/local/bin/
3131

32-
# macOS (Intel)
33-
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-macos-amd64.tar.gz | tar xz
34-
sudo mv dot /usr/local/bin/
35-
3632
# macOS (Apple Silicon)
37-
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-macos-arm64.tar.gz | tar xz
33+
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-macos-apple-silicon.tar.gz | tar xz
3834
sudo mv dot /usr/local/bin/
3935
```
4036

@@ -63,10 +59,7 @@ dot setup
6359

6460
```bash
6561
# Interactive mode (recommended)
66-
dot
67-
68-
# Or with a slug
69-
dot my-recipe-name
62+
dot recipe create
7063
```
7164

7265
The CLI will guide you through:
@@ -149,22 +142,20 @@ dot setup # Check and setup your environment
149142
dot doctor # Run comprehensive health checks
150143

151144
# Recipe management
152-
dot # Create recipe (interactive)
153-
dot <slug> # Create recipe with slug
154-
dot recipe new # Create recipe (explicit command)
155-
dot recipe list # List all recipes
156-
dot recipe test # Test a recipe
145+
dot recipe create # Create recipe (interactive)
146+
dot recipe list # List all recipes
147+
dot recipe test # Test a recipe
157148
dot recipe validate # Validate recipe structure
158-
dot recipe lint # Run linting checks
159-
dot recipe submit # Submit as pull request
149+
dot recipe lint # Run linting checks
150+
dot recipe submit # Submit as pull request
160151

161152
# Non-interactive mode
162-
dot my-recipe \
163-
--non-interactive \
153+
dot recipe create \
164154
--title "My Recipe Title" \
165155
--pathway runtime \
166156
--difficulty beginner \
167-
--content-type tutorial
157+
--content-type tutorial \
158+
--non-interactive
168159
```
169160

170161
<hr />

README.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,8 @@ cargo build --release
108108
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-linux-amd64.tar.gz | tar xz
109109
sudo mv dot /usr/local/bin/
110110

111-
# macOS (Intel)
112-
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-macos-amd64.tar.gz | tar xz
113-
sudo mv dot /usr/local/bin/
114-
115111
# macOS (Apple Silicon)
116-
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-macos-arm64.tar.gz | tar xz
112+
curl -L https://github.com/polkadot-developers/polkadot-cookbook/releases/latest/download/dot-macos-apple-silicon.tar.gz | tar xz
117113
sudo mv dot /usr/local/bin/
118114
```
119115

@@ -132,10 +128,7 @@ dot setup
132128
dot doctor
133129

134130
# Create a new recipe (interactive mode)
135-
dot
136-
137-
# Or create with a specific slug
138-
dot my-pallet
131+
dot recipe create
139132

140133
# Test your recipe
141134
dot recipe test my-pallet

cli/README.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ export PATH="$PATH:/path/to/polkadot-cookbook/target/release"
2828
### Create a Recipe (Interactive)
2929

3030
```bash
31-
dot create
31+
dot recipe create
3232
```
3333

3434
This launches an interactive prompt that guides you through recipe creation.
3535

36-
### Create a Recipe (Command Line)
36+
### Create a Recipe (Non-Interactive)
3737

3838
```bash
39-
dot create my-awesome-recipe
39+
dot recipe create --title "My Awesome Recipe" --non-interactive
4040
```
4141

4242
### View Versions
@@ -54,36 +54,37 @@ dot versions my-recipe --show-source
5454

5555
## Commands
5656

57-
### `create`
57+
### `recipe create`
5858

5959
Create a new recipe with scaffolded structure.
6060

6161
**Usage:**
6262
```bash
63-
dot create [OPTIONS] [SLUG]
63+
dot recipe create [OPTIONS]
6464
```
6565

66-
**Arguments:**
67-
- `SLUG` - Recipe slug (e.g., "my-recipe"). Optional in interactive mode.
68-
6966
**Options:**
67+
- `--title <TITLE>` - Recipe title (required in non-interactive mode)
68+
- `--pathway <PATHWAY>` - Recipe pathway: runtime, contracts, basic-interaction, xcm, testing
69+
- `--difficulty <DIFFICULTY>` - Difficulty level: beginner, intermediate, advanced
70+
- `--content-type <TYPE>` - Content type: tutorial, guide
7071
- `--skip-install` - Skip npm dependency installation
7172
- `--no-git` - Skip git branch creation
72-
- `--non-interactive` - Non-interactive mode (requires SLUG)
73+
- `--non-interactive` - Non-interactive mode (requires --title)
7374

7475
**Examples:**
7576
```bash
7677
# Interactive mode (recommended)
77-
dot create
78+
dot recipe create
7879

79-
# With slug
80-
dot create custom-pallet-recipe
80+
# Non-interactive with title (slug auto-generated)
81+
dot recipe create --title "Custom Pallet Recipe"
8182

8283
# Skip installation for faster creation
83-
dot create my-recipe --skip-install
84+
dot recipe create --title "My Recipe" --skip-install --non-interactive
8485

85-
# CI/CD mode
86-
dot create my-recipe --non-interactive --skip-install
86+
# CI/CD mode with full options
87+
dot recipe create --title "My Recipe" --pathway runtime --difficulty beginner --non-interactive --skip-install
8788
```
8889

8990
**What it creates:**
@@ -160,7 +161,7 @@ versions:
160161

161162
```bash
162163
# 1. Create recipe structure
163-
dot create my-awesome-recipe
164+
dot recipe create --title "My Awesome Recipe"
164165

165166
# 2. Write content
166167
cd recipes/my-awesome-recipe
@@ -185,7 +186,7 @@ git push origin recipe/my-awesome-recipe
185186

186187
```bash
187188
# Create recipe
188-
dot create test-new-version
189+
dot recipe create --title "Test New Version"
189190

190191
# Edit versions
191192
cd recipes/test-new-version
@@ -231,17 +232,17 @@ Edit `recipes/<slug>/recipe.config.yml` to configure:
231232

232233
```bash
233234
cd /path/to/polkadot-cookbook
234-
dot create my-recipe
235+
dot recipe create --title "My Recipe"
235236
```
236237

237-
### "Slug argument is required"
238+
### "Title argument is required"
238239

239-
**Problem:** Non-interactive mode without slug
240+
**Problem:** Non-interactive mode without title
240241

241-
**Solution:** Provide slug argument
242+
**Solution:** Provide --title argument
242243

243244
```bash
244-
dot create my-recipe --non-interactive
245+
dot recipe create --title "My Recipe" --non-interactive
245246
```
246247

247248
### "Failed to resolve versions"

0 commit comments

Comments
 (0)