Skip to main content

fraiseql_cli/
cli.rs

1//! CLI argument definitions: `Cli` struct, `Commands` enum, and all sub-command enums.
2
3use clap::{Parser, Subcommand};
4
5/// Exit codes documented in help text
6pub(crate) const EXIT_CODES_HELP: &str = "\
7EXIT CODES:
8    0  Success - Command completed successfully
9    1  Error - Command failed with an error
10    2  Validation failed - Schema or input validation failed";
11
12/// FraiseQL CLI - Compile GraphQL schemas to optimized SQL execution
13#[derive(Parser)]
14#[command(name = "fraiseql")]
15#[command(author, version, about, long_about = None)]
16#[command(propagate_version = true)]
17#[command(after_help = EXIT_CODES_HELP)]
18pub(crate) struct Cli {
19    /// Enable verbose logging
20    #[arg(short, long, global = true)]
21    pub(crate) verbose: bool,
22
23    /// Enable debug logging
24    #[arg(short, long, global = true)]
25    pub(crate) debug: bool,
26
27    /// Output as JSON (machine-readable)
28    #[arg(long, global = true)]
29    pub(crate) json: bool,
30
31    /// Suppress output (exit code only)
32    #[arg(short, long, global = true)]
33    pub(crate) quiet: bool,
34
35    #[command(subcommand)]
36    pub(crate) command: Commands,
37}
38
39#[derive(Subcommand)]
40pub(crate) enum Commands {
41    /// Compile schema to optimized schema.compiled.json
42    ///
43    /// Supports three workflows:
44    /// 1. TOML-only: fraiseql compile fraiseql.toml
45    /// 2. Language + TOML: fraiseql compile fraiseql.toml --types types.json
46    /// 3. Legacy JSON: fraiseql compile schema.json
47    #[command(after_help = "\
48EXAMPLES:
49    fraiseql compile fraiseql.toml
50    fraiseql compile fraiseql.toml --types types.json
51    fraiseql compile schema.json -o schema.compiled.json
52    fraiseql compile fraiseql.toml --check")]
53    Compile {
54        /// Input file path: fraiseql.toml (TOML) or schema.json (legacy)
55        #[arg(value_name = "INPUT")]
56        input: String,
57
58        /// Optional types.json from language implementation (used with fraiseql.toml)
59        #[arg(long, value_name = "TYPES")]
60        types: Option<String>,
61
62        /// Directory for auto-discovery of schema files (recursive *.json)
63        #[arg(long, value_name = "DIR")]
64        schema_dir: Option<String>,
65
66        /// Type files (repeatable): fraiseql compile fraiseql.toml --type-file a.json --type-file
67        /// b.json
68        #[arg(long = "type-file", value_name = "FILE")]
69        type_files: Vec<String>,
70
71        /// Query files (repeatable)
72        #[arg(long = "query-file", value_name = "FILE")]
73        query_files: Vec<String>,
74
75        /// Mutation files (repeatable)
76        #[arg(long = "mutation-file", value_name = "FILE")]
77        mutation_files: Vec<String>,
78
79        /// Output schema.compiled.json file path
80        #[arg(
81            short,
82            long,
83            value_name = "OUTPUT",
84            default_value = "schema.compiled.json"
85        )]
86        output: String,
87
88        /// Validate only, don't write output
89        #[arg(long)]
90        check: bool,
91
92        /// Skip embedding content hash in compiled schema (for test fixtures)
93        #[arg(long)]
94        skip_hash: bool,
95
96        /// Optional database URL for indexed column validation
97        /// When provided, validates that indexed columns exist in database views
98        #[arg(long, value_name = "DATABASE_URL")]
99        database: Option<String>,
100
101        /// Emit DDL files for all schema types to the given directory
102        ///
103        /// Writes `CREATE TABLE` DDL for each compiled type to `<DIR>/<type>.sql`.
104        /// Output is compatible with confiture's `db/schema/` directory format,
105        /// enabling `fraiseql migrate generate` to auto-detect schema drift.
106        #[arg(long, value_name = "DIR")]
107        emit_ddl: Option<String>,
108
109        /// Check compiled schema against the database for migration drift
110        ///
111        /// Emits DDL to a temporary directory, then delegates to
112        /// `confiture migrate validate` for drift detection.
113        /// Exits non-zero when the compiled schema diverges from the database.
114        #[arg(long)]
115        check_migrations: bool,
116    },
117
118    /// Extract schema from annotated source files
119    ///
120    /// Parses FraiseQL annotations in any supported language and generates schema.json.
121    /// No language runtime required — pure text processing.
122    #[command(after_help = "\
123EXAMPLES:
124    fraiseql extract schema/schema.py
125    fraiseql extract schema/ --recursive
126    fraiseql extract schema.rs --language rust -o schema.json")]
127    Extract {
128        /// Source file(s) or directory to extract from
129        #[arg(value_name = "INPUT")]
130        input: Vec<String>,
131
132        /// Override language detection (python, typescript, rust, java, kotlin, go, csharp, swift,
133        /// scala)
134        #[arg(short, long)]
135        language: Option<String>,
136
137        /// Recursively scan directories
138        #[arg(short, long)]
139        recursive: bool,
140
141        /// Output file path
142        #[arg(short, long, default_value = "schema.json")]
143        output: String,
144    },
145
146    /// Explain query execution plan and complexity
147    ///
148    /// Shows GraphQL query execution plan, SQL, and complexity analysis.
149    #[command(after_help = "\
150EXAMPLES:
151    fraiseql explain '{ users { id name } }'
152    fraiseql explain '{ user(id: 1) { posts { title } } }' --json")]
153    Explain {
154        /// GraphQL query string
155        #[arg(value_name = "QUERY")]
156        query: String,
157    },
158
159    /// Calculate query complexity score
160    ///
161    /// Quick analysis of query complexity (depth, field count, score).
162    #[command(after_help = "\
163EXAMPLES:
164    fraiseql cost '{ users { id name } }'
165    fraiseql cost '{ deeply { nested { query { here } } } }' --json")]
166    Cost {
167        /// GraphQL query string
168        #[arg(value_name = "QUERY")]
169        query: String,
170    },
171
172    /// Analyze schema for optimization opportunities
173    ///
174    /// Provides recommendations across 6 categories:
175    /// performance, security, federation, complexity, caching, indexing
176    #[command(after_help = "\
177EXAMPLES:
178    fraiseql analyze schema.compiled.json
179    fraiseql analyze schema.compiled.json --json")]
180    Analyze {
181        /// Path to schema.compiled.json
182        #[arg(value_name = "SCHEMA")]
183        schema: String,
184    },
185
186    /// Analyze schema type dependencies
187    ///
188    /// Exports dependency graph, detects cycles, and finds unused types.
189    /// Supports multiple output formats for visualization and CI integration.
190    #[command(after_help = "\
191EXAMPLES:
192    fraiseql dependency-graph schema.compiled.json
193    fraiseql dependency-graph schema.compiled.json -f dot > graph.dot
194    fraiseql dependency-graph schema.compiled.json -f mermaid
195    fraiseql dependency-graph schema.compiled.json --json")]
196    DependencyGraph {
197        /// Path to schema.compiled.json
198        #[arg(value_name = "SCHEMA")]
199        schema: String,
200
201        /// Output format (json, dot, mermaid, d2, console)
202        #[arg(short, long, value_name = "FORMAT", default_value = "json")]
203        format: String,
204    },
205
206    /// Export federation dependency graph
207    ///
208    /// Visualize federation structure in multiple formats.
209    #[command(after_help = "\
210EXAMPLES:
211    fraiseql federation graph schema.compiled.json
212    fraiseql federation graph schema.compiled.json -f dot
213    fraiseql federation graph schema.compiled.json -f mermaid")]
214    Federation {
215        /// Schema path (positional argument passed to subcommand)
216        #[command(subcommand)]
217        command: FederationCommands,
218    },
219
220    /// Lint schema for FraiseQL design quality
221    ///
222    /// Analyzes schema using FraiseQL-calibrated design rules.
223    /// Detects JSONB batching issues, compilation problems, auth boundaries, etc.
224    #[command(after_help = "\
225EXAMPLES:
226    fraiseql lint schema.json
227    fraiseql lint schema.compiled.json --federation
228    fraiseql lint schema.json --fail-on-critical
229    fraiseql lint schema.json --json")]
230    Lint {
231        /// Path to schema.json or schema.compiled.json
232        #[arg(value_name = "SCHEMA")]
233        schema: String,
234
235        /// Only show federation audit
236        #[arg(long)]
237        federation: bool,
238
239        /// Only show cost audit
240        #[arg(long)]
241        cost: bool,
242
243        /// Only show cache audit
244        #[arg(long)]
245        cache: bool,
246
247        /// Only show auth audit
248        #[arg(long)]
249        auth: bool,
250
251        /// Only show compilation audit
252        #[arg(long)]
253        compilation: bool,
254
255        /// Exit with error if any critical issues found
256        #[arg(long)]
257        fail_on_critical: bool,
258
259        /// Exit with error if any warning or critical issues found
260        #[arg(long)]
261        fail_on_warning: bool,
262
263        /// Show detailed issue descriptions
264        #[arg(long)]
265        verbose: bool,
266    },
267
268    /// Generate DDL for Arrow views (va_*, tv_*, ta_*)
269    #[command(after_help = "\
270EXAMPLES:
271    fraiseql generate-views -s schema.json -e User --view va_users
272    fraiseql generate-views -s schema.json -e Order --view tv_orders --refresh-strategy scheduled")]
273    GenerateViews {
274        /// Path to schema.json
275        #[arg(short, long, value_name = "SCHEMA")]
276        schema: String,
277
278        /// Entity name from schema
279        #[arg(short, long, value_name = "NAME")]
280        entity: String,
281
282        /// View name (must start with va_, tv_, or ta_)
283        #[arg(long, value_name = "NAME")]
284        view: String,
285
286        /// Refresh strategy (trigger-based or scheduled)
287        #[arg(long, value_name = "STRATEGY", default_value = "trigger-based")]
288        refresh_strategy: String,
289
290        /// Output file path (default: {view}.sql)
291        #[arg(short, long, value_name = "PATH")]
292        output: Option<String>,
293
294        /// Include helper/composition views
295        #[arg(long, default_value = "true")]
296        include_composition_views: bool,
297
298        /// Include monitoring functions
299        #[arg(long, default_value = "true")]
300        include_monitoring: bool,
301
302        /// Validate only, don't write file
303        #[arg(long)]
304        validate: bool,
305
306        /// Show generation steps (use global --verbose flag)
307        #[arg(long, action = clap::ArgAction::SetTrue)]
308        gen_verbose: bool,
309    },
310
311    /// Validate schema.json or fact tables
312    ///
313    /// Performs comprehensive schema validation including:
314    /// - JSON structure validation
315    /// - Type reference validation
316    /// - Circular dependency detection (with --check-cycles)
317    /// - Unused type detection (with --check-unused)
318    #[command(after_help = "\
319EXAMPLES:
320    fraiseql validate schema.json
321    fraiseql validate schema.json --check-unused
322    fraiseql validate schema.json --strict
323    fraiseql validate facts -s schema.json -d postgres://localhost/db")]
324    Validate {
325        #[command(subcommand)]
326        command: Option<ValidateCommands>,
327
328        /// Schema.json file path to validate (if no subcommand)
329        #[arg(value_name = "INPUT")]
330        input: Option<String>,
331
332        /// Check for circular dependencies between types
333        #[arg(long, default_value = "true")]
334        check_cycles: bool,
335
336        /// Check for unused types (no incoming references)
337        #[arg(long)]
338        check_unused: bool,
339
340        /// Strict mode: treat warnings as errors (unused types become errors)
341        #[arg(long)]
342        strict: bool,
343
344        /// Only analyze specific type(s) - comma-separated list
345        #[arg(long, value_name = "TYPES", value_delimiter = ',')]
346        types: Vec<String>,
347    },
348
349    /// Introspect database for fact tables and output suggestions
350    #[command(after_help = "\
351EXAMPLES:
352    fraiseql introspect facts -d postgres://localhost/db
353    fraiseql introspect facts -d postgres://localhost/db -f json")]
354    Introspect {
355        #[command(subcommand)]
356        command: IntrospectCommands,
357    },
358
359    /// Generate authoring-language source from schema.json
360    ///
361    /// The inverse of `fraiseql extract`: reads a schema.json and produces annotated
362    /// source code in any of the 9 supported authoring languages.
363    #[command(after_help = "\
364EXAMPLES:
365    fraiseql generate schema.json --language python
366    fraiseql generate schema.json --language rust -o schema.rs
367    fraiseql generate schema.json --language typescript")]
368    Generate {
369        /// Path to schema.json
370        #[arg(value_name = "INPUT")]
371        input: String,
372
373        /// Target language (python, typescript, rust, java, kotlin, go, csharp, swift, scala)
374        #[arg(short, long)]
375        language: String,
376
377        /// Output file path (default: schema.<ext> based on language)
378        #[arg(short, long)]
379        output: Option<String>,
380    },
381
382    /// Generate consumer-side typed clients from a compiled schema
383    ///
384    /// Distinct from `generate`: `generate` emits server-side authoring code (write
385    /// FraiseQL types in another language, fed back into the compiler), whereas
386    /// `generate-client` emits a typed client for callers of a FraiseQL API
387    /// (interfaces + query/mutation functions) from a compiled schema.compiled.json.
388    #[command(after_help = "\
389EXAMPLES:
390    fraiseql generate-client typescript --out ./src/generated
391    fraiseql generate-client typescript --schema ./schema.compiled.json --out ./gen --force")]
392    GenerateClient {
393        #[command(subcommand)]
394        language: GenerateClientCommands,
395    },
396
397    /// Initialize a new FraiseQL project
398    ///
399    /// Creates project directory with fraiseql.toml, schema.json,
400    /// database DDL structure, and authoring skeleton.
401    #[command(after_help = "\
402EXAMPLES:
403    fraiseql init my-app
404    fraiseql init my-app --language typescript --database postgres
405    fraiseql init my-app --size xs --no-git")]
406    Init {
407        /// Project name (used as directory name)
408        #[arg(value_name = "PROJECT_NAME")]
409        project_name: String,
410
411        /// Authoring language (python, typescript, rust, java, kotlin, go, csharp, swift, scala)
412        #[arg(short, long, default_value = "python")]
413        language: String,
414
415        /// Target database (postgres, mysql, sqlite, sqlserver)
416        #[arg(long, default_value = "postgres")]
417        database: String,
418
419        /// Project size: xs (single file), s (flat dirs), m (per-entity dirs)
420        #[arg(long, default_value = "s")]
421        size: String,
422
423        /// Skip git init
424        #[arg(long)]
425        no_git: bool,
426    },
427
428    /// Run database migrations
429    ///
430    /// Wraps confiture for a unified migration experience.
431    /// Reads database URL from --database, fraiseql.toml, or DATABASE_URL env var.
432    #[command(after_help = "\
433EXAMPLES:
434    fraiseql migrate up --database postgres://localhost/mydb
435    fraiseql migrate down --steps 1
436    fraiseql migrate status
437    fraiseql migrate create add_posts_table")]
438    Migrate {
439        #[command(subcommand)]
440        command: MigrateCommands,
441    },
442
443    /// Generate Software Bill of Materials
444    ///
445    /// Parses Cargo.lock and fraiseql.toml to produce a compliance-ready SBOM.
446    #[command(after_help = "\
447EXAMPLES:
448    fraiseql sbom
449    fraiseql sbom --format spdx
450    fraiseql sbom --format cyclonedx --output sbom.json")]
451    Sbom {
452        /// Output format (cyclonedx, spdx)
453        #[arg(short, long, default_value = "cyclonedx")]
454        format: String,
455
456        /// Output file path (default: stdout)
457        #[arg(short, long, value_name = "FILE")]
458        output: Option<String>,
459    },
460
461    /// Compile schema and immediately start the GraphQL server
462    ///
463    /// Compiles the schema in-memory (no disk artifact) and starts the HTTP server.
464    /// With --watch, the server hot-reloads whenever the schema file changes.
465    ///
466    /// Server and database settings can be declared in fraiseql.toml under [server]
467    /// and [database] sections.  CLI flags take precedence over TOML settings, which
468    /// take precedence over defaults.  The database URL is resolved in this order:
469    /// --database flag > DATABASE_URL env var > [database].url in fraiseql.toml.
470    #[cfg(feature = "run-server")]
471    #[command(after_help = "\
472EXAMPLES:
473    fraiseql run
474    fraiseql run fraiseql.toml --database postgres://localhost/mydb
475    fraiseql run --port 3000 --watch
476    fraiseql run schema.json --introspection
477
478TOML CONFIG:
479    [server]
480    host = \"127.0.0.1\"
481    port = 9000
482
483    [server.cors]
484    origins = [\"https://app.example.com\"]
485
486    [database]
487    url      = \"${DATABASE_URL}\"
488    pool_min = 2
489    pool_max = 20")]
490    Run {
491        /// Input file path (fraiseql.toml or schema.json); auto-detected if omitted
492        #[arg(value_name = "INPUT")]
493        input: Option<String>,
494
495        /// Database URL (overrides [database].url in fraiseql.toml and DATABASE_URL env var)
496        #[arg(short, long, value_name = "DATABASE_URL")]
497        database: Option<String>,
498
499        /// Port to listen on (overrides [server].port in fraiseql.toml)
500        #[arg(short, long, value_name = "PORT")]
501        port: Option<u16>,
502
503        /// Bind address (overrides [server].host in fraiseql.toml)
504        #[arg(long, value_name = "HOST")]
505        bind: Option<String>,
506
507        /// Watch input file for changes and hot-reload the server
508        #[arg(short, long)]
509        watch: bool,
510
511        /// Enable the GraphQL introspection endpoint (no auth required)
512        #[arg(long)]
513        introspection: bool,
514    },
515
516    /// Validate a trusted documents manifest
517    ///
518    /// Checks that the manifest JSON is well-formed and that each key
519    /// is a valid SHA-256 hex string matching its query body.
520    #[command(after_help = "\
521EXAMPLES:
522    fraiseql validate-documents manifest.json")]
523    ValidateDocuments {
524        /// Path to the trusted documents manifest JSON file
525        #[arg(value_name = "MANIFEST")]
526        manifest: String,
527    },
528
529    /// Development server with hot-reload
530    #[command(hide = true)] // Hide until implemented
531    Serve {
532        /// Schema.json file path to watch
533        #[arg(value_name = "SCHEMA")]
534        schema: String,
535
536        /// Port to listen on
537        #[arg(short, long, default_value = "8080")]
538        port: u16,
539    },
540
541    /// Install FraiseQL mutation helper functions
542    ///
543    /// Installs SQL helper functions (fraiseql.mutation_ok, fraiseql.mutation_err, etc.)
544    /// to reduce boilerplate when writing mutation functions under the v2.2.0 protocol.
545    /// The helpers are installed in the `fraiseql` schema, which is owned by FraiseQL's
546    /// database role.
547    #[command(after_help = "\
548EXAMPLES:
549    fraiseql setup --database postgres://localhost/mydb
550    fraiseql setup --dry-run
551    fraiseql setup  # Uses DATABASE_URL or [database].url from fraiseql.toml")]
552    Setup {
553        /// Database connection URL (or use DATABASE_URL env var, or [database].url in
554        /// fraiseql.toml)
555        #[arg(long, value_name = "DATABASE_URL")]
556        database: Option<String>,
557
558        /// Print SQL without applying changes
559        #[arg(long)]
560        dry_run: bool,
561    },
562
563    /// Inspect schema metadata from a running FraiseQL server
564    ///
565    /// Fetches field-level security metadata (encryption, scope requirements, deny actions)
566    /// from the server's `/api/v1/schema/metadata` endpoint and displays it as a table.
567    #[command(after_help = "\
568EXAMPLES:
569    fraiseql schema metadata
570    fraiseql schema metadata --server http://localhost:8080
571    fraiseql schema metadata --server https://api.example.com --token mytoken")]
572    Schema {
573        #[command(subcommand)]
574        command: SchemaCommands,
575    },
576
577    /// Run diagnostic checks for common FraiseQL setup problems
578    ///
579    /// Checks schema file, TOML config, DATABASE_URL, JWT secret, Redis, TLS,
580    /// and cache/auth coherence. Prints a color-coded report and exits 0 if
581    /// all checks pass or 1 if any check fails (warnings do not fail).
582    #[command(after_help = "\
583EXAMPLES:
584    fraiseql doctor
585    fraiseql doctor --schema schema.compiled.json --config fraiseql.toml
586    fraiseql doctor --db-url postgres://user:pass@host:5432/db
587    fraiseql doctor --json")]
588    Doctor {
589        /// Path to fraiseql.toml configuration file.
590        #[arg(long, default_value = "fraiseql.toml")]
591        config: std::path::PathBuf,
592
593        /// Path to schema.compiled.json.
594        #[arg(long, default_value = "schema.compiled.json")]
595        schema: std::path::PathBuf,
596
597        /// Override DATABASE_URL for the connectivity check.
598        #[arg(long)]
599        db_url: Option<String>,
600
601        /// Output machine-readable JSON (for CI integration).
602        #[arg(long)]
603        json: bool,
604    },
605}
606
607#[derive(Subcommand)]
608pub(crate) enum ValidateCommands {
609    /// Validate that declared fact tables match database schema
610    Facts {
611        /// Schema.json file path
612        #[arg(short, long, value_name = "SCHEMA")]
613        schema: String,
614
615        /// Database connection string
616        #[arg(short, long, value_name = "DATABASE_URL")]
617        database: String,
618    },
619}
620
621#[derive(Subcommand)]
622pub(crate) enum GenerateClientCommands {
623    /// Generate a TypeScript client (interfaces + typed query/mutation functions).
624    Typescript {
625        /// Path to schema.compiled.json (auto-detected from conventional
626        /// locations if omitted).
627        #[arg(long, value_name = "SCHEMA")]
628        schema: Option<std::path::PathBuf>,
629
630        /// Output directory for the generated client.
631        #[arg(long, value_name = "DIR")]
632        out: std::path::PathBuf,
633
634        /// Overwrite an existing generated client in the output directory.
635        #[arg(long, default_value_t = false)]
636        force: bool,
637    },
638}
639
640#[derive(Subcommand)]
641pub(crate) enum FederationCommands {
642    /// Export federation graph
643    Graph {
644        /// Path to schema.compiled.json
645        #[arg(value_name = "SCHEMA")]
646        schema: String,
647
648        /// Output format (json, dot, mermaid)
649        #[arg(short, long, value_name = "FORMAT", default_value = "json")]
650        format: String,
651    },
652
653    /// Validate subgraph composition
654    Check {
655        /// Path to local schema.compiled.json
656        #[arg(value_name = "SCHEMA")]
657        schema: String,
658
659        /// Path to supergraph schema for composition validation
660        #[arg(short, long, value_name = "SUPERGRAPH")]
661        against: Option<String>,
662
663        /// Output result as JSON
664        #[arg(long)]
665        json: bool,
666    },
667}
668
669#[derive(Subcommand)]
670pub(crate) enum IntrospectCommands {
671    /// Introspect database for fact tables (tf_* tables)
672    Facts {
673        /// Database connection string
674        #[arg(short, long, value_name = "DATABASE_URL")]
675        database: String,
676
677        /// Output format (python, json)
678        #[arg(short, long, value_name = "FORMAT", default_value = "python")]
679        format: String,
680    },
681}
682
683#[derive(Subcommand)]
684pub(crate) enum SchemaCommands {
685    /// Display field-level security metadata from a running server
686    Metadata {
687        /// Server base URL
688        #[arg(
689            short,
690            long,
691            value_name = "URL",
692            default_value = "http://localhost:8080"
693        )]
694        server: String,
695
696        /// Bearer token for authentication
697        #[arg(short, long, value_name = "TOKEN")]
698        token: Option<String>,
699    },
700}
701
702#[derive(Subcommand)]
703pub(crate) enum MigrateCommands {
704    /// Apply pending migrations
705    Up {
706        /// Database connection URL
707        #[arg(long, value_name = "DATABASE_URL")]
708        database: Option<String>,
709
710        /// Migration directory
711        #[arg(long, value_name = "DIR")]
712        dir: Option<String>,
713    },
714
715    /// Roll back migrations
716    Down {
717        /// Database connection URL
718        #[arg(long, value_name = "DATABASE_URL")]
719        database: Option<String>,
720
721        /// Migration directory
722        #[arg(long, value_name = "DIR")]
723        dir: Option<String>,
724
725        /// Number of migrations to roll back
726        #[arg(long, default_value = "1")]
727        steps: u32,
728    },
729
730    /// Show migration status
731    Status {
732        /// Database connection URL
733        #[arg(long, value_name = "DATABASE_URL")]
734        database: Option<String>,
735
736        /// Migration directory
737        #[arg(long, value_name = "DIR")]
738        dir: Option<String>,
739    },
740
741    /// Create a new migration file
742    Create {
743        /// Migration name
744        #[arg(value_name = "NAME")]
745        name: String,
746
747        /// Migration directory
748        #[arg(long, value_name = "DIR")]
749        dir: Option<String>,
750    },
751
752    /// Generate a new migration from schema diff
753    ///
754    /// Delegates to `confiture migrate generate`.
755    /// Creates a timestamped migration file.
756    Generate {
757        /// Migration name
758        #[arg(value_name = "NAME")]
759        name: String,
760
761        /// Migration directory
762        #[arg(long, value_name = "DIR")]
763        dir: Option<String>,
764    },
765
766    /// Validate migration files for naming, idempotency, and drift
767    ///
768    /// Delegates to `confiture migrate validate`.
769    /// Checks naming conventions, idempotency, and schema drift.
770    Validate {
771        /// Migration directory
772        #[arg(long, value_name = "DIR")]
773        dir: Option<String>,
774    },
775
776    /// Pre-deploy safety check on pending migrations
777    ///
778    /// Delegates to `confiture migrate preflight`.
779    /// Verifies reversibility, detects non-transactional statements, checks checksums.
780    Preflight {
781        /// Migration directory
782        #[arg(long, value_name = "DIR")]
783        dir: Option<String>,
784    },
785}