oxirs 0.2.4

Command-line interface for OxiRS - import, export, migration, and benchmarking tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
//! CLI action enums for various oxirs commands
//!
//! This module contains all the action enum definitions used by the main Commands enum.
//! These were extracted from lib.rs to keep the main module under 2000 lines.

use clap::Subcommand;
use std::path::PathBuf;

/// CI/CD integration actions
#[derive(Subcommand)]
pub enum CicdAction {
    /// Generate test report from benchmark results
    Report {
        /// Input benchmark results file (JSON)
        input: PathBuf,
        /// Output report file
        #[arg(short, long)]
        output: PathBuf,
        /// Report format (junit, tap, json)
        #[arg(short, long, default_value = "junit")]
        format: String,
    },
    /// Generate Docker integration files
    Docker {
        /// Output directory for Docker files
        #[arg(short, long, default_value = ".")]
        output: PathBuf,
    },
    /// Generate GitHub Actions workflow
    Github {
        /// Output file path
        #[arg(short, long, default_value = ".github/workflows/ci.yml")]
        output: PathBuf,
    },
    /// Generate GitLab CI configuration
    Gitlab {
        /// Output file path
        #[arg(short, long, default_value = ".gitlab-ci.yml")]
        output: PathBuf,
    },
}

/// Cache management actions
#[derive(Subcommand)]
pub enum CacheAction {
    /// Show cache statistics
    Stats,
    /// Clear the query cache
    Clear,
    /// Configure cache settings
    Config {
        /// TTL in seconds
        #[arg(long)]
        ttl: Option<u64>,
        /// Maximum cache size
        #[arg(long)]
        max_size: Option<usize>,
    },
}

/// Alias management actions
#[derive(Subcommand)]
pub enum AliasAction {
    /// List all aliases
    List,
    /// Show a specific alias
    Show {
        /// Alias name
        name: String,
    },
    /// Add or update an alias
    Add {
        /// Alias name
        name: String,
        /// Command to alias
        command: String,
    },
    /// Remove an alias
    Remove {
        /// Alias name
        name: String,
    },
    /// Reset aliases to defaults
    Reset,
}

/// Index management actions
#[derive(Subcommand)]
pub enum IndexAction {
    /// List all indexes in a dataset
    List {
        /// Dataset name or path
        dataset: String,
    },
    /// Rebuild indexes for better performance
    Rebuild {
        /// Dataset name or path
        dataset: String,
        /// Specific index name to rebuild (omit to rebuild all)
        #[arg(long)]
        index: Option<String>,
    },
    /// Show detailed index statistics
    Stats {
        /// Dataset name or path
        dataset: String,
        /// Output format (text, json, csv)
        #[arg(short, long, default_value = "text")]
        format: String,
    },
    /// Optimize indexes to reduce fragmentation
    Optimize {
        /// Dataset name or path
        dataset: String,
    },
}

/// Configuration management actions
#[derive(Subcommand)]
pub enum ConfigAction {
    /// Generate a default configuration file
    Init {
        /// Output file path
        #[arg(short, long, default_value = "oxirs.toml")]
        output: PathBuf,
    },
    /// Validate a configuration file
    Validate {
        /// Configuration file path
        config: PathBuf,
    },
    /// Show current configuration
    Show {
        /// Configuration file path
        config: Option<PathBuf>,
    },
}

/// SPARQL query template actions
#[derive(Subcommand)]
pub enum TemplateAction {
    /// List all available templates
    List {
        /// Filter by category (basic, advanced, analytics, graph, federation, paths, aggregation)
        #[arg(long)]
        category: Option<String>,
    },
    /// Show template details
    Show {
        /// Template name
        name: String,
    },
    /// Render a template with parameters
    Render {
        /// Template name
        name: String,
        /// Template parameters in key=value format (repeatable)
        #[arg(short, long)]
        param: Vec<String>,
    },
}

/// Query history actions
#[derive(Subcommand)]
pub enum HistoryAction {
    /// List query history
    List {
        /// Maximum number of entries to show
        #[arg(short, long, default_value = "20")]
        limit: Option<usize>,
        /// Filter by dataset
        #[arg(short, long)]
        dataset: Option<String>,
    },
    /// Show full query details
    Show {
        /// History entry ID
        id: usize,
    },
    /// Replay a query from history
    Replay {
        /// History entry ID
        id: usize,
        /// Output format
        #[arg(short, long)]
        output: Option<String>,
    },
    /// Search query history
    Search {
        /// Query text to search for
        query: String,
    },
    /// Clear query history
    Clear,
    /// Show history statistics
    Stats,
    /// Show comprehensive query analytics
    Analytics {
        /// Filter by dataset
        #[arg(short, long)]
        dataset: Option<String>,
    },
}

/// Migration actions for converting between databases and formats
#[derive(Subcommand)]
pub enum MigrateAction {
    /// Convert RDF data between formats (turtle, ntriples, etc.)
    Format {
        /// Source file path
        source: PathBuf,
        /// Target file path
        target: PathBuf,
        /// Source format
        #[arg(long)]
        from: String,
        /// Target format
        #[arg(long)]
        to: String,
    },
    /// Migrate from Apache Jena TDB1 database to OxiRS
    FromTdb1 {
        /// TDB1 database directory
        tdb_dir: PathBuf,
        /// Target OxiRS dataset name
        dataset: String,
        /// Skip validation (faster but less safe)
        #[arg(long)]
        skip_validation: bool,
    },
    /// Migrate from Apache Jena TDB2 database to OxiRS
    FromTdb2 {
        /// TDB2 database directory
        tdb_dir: PathBuf,
        /// Target OxiRS dataset name
        dataset: String,
        /// Skip validation (faster but less safe)
        #[arg(long)]
        skip_validation: bool,
    },
    /// Migrate from Virtuoso database to OxiRS
    FromVirtuoso {
        /// Virtuoso connection string
        connection: String,
        /// Target OxiRS dataset name
        dataset: String,
        /// Graph URIs to migrate (comma-separated, or 'all')
        #[arg(long, default_value = "all")]
        graphs: String,
    },
    /// Migrate from RDF4J repository to OxiRS
    FromRdf4j {
        /// RDF4J repository directory
        repo_dir: PathBuf,
        /// Target OxiRS dataset name
        dataset: String,
    },
    /// Migrate from Blazegraph database to OxiRS
    FromBlazegraph {
        /// Blazegraph SPARQL endpoint URL
        endpoint: String,
        /// Target OxiRS dataset name
        dataset: String,
        /// Namespace to migrate
        #[arg(long, default_value = "kb")]
        namespace: String,
    },
    /// Migrate from Ontotext GraphDB to OxiRS
    FromGraphdb {
        /// GraphDB SPARQL endpoint URL
        endpoint: String,
        /// Target OxiRS dataset name
        dataset: String,
        /// Repository name
        #[arg(long)]
        repository: String,
    },
}

/// Point-in-Time Recovery (PITR) actions
#[derive(Subcommand)]
pub enum PitrAction {
    /// Initialize transaction logging for a dataset
    Init {
        /// Dataset directory
        dataset: PathBuf,
        /// Maximum log file size in MB
        #[arg(long, default_value = "100")]
        max_log_size: u64,
        /// Enable auto-archival of old logs
        #[arg(long)]
        auto_archive: bool,
    },
    /// Create a named checkpoint
    Checkpoint {
        /// Dataset directory
        dataset: PathBuf,
        /// Checkpoint name
        name: String,
    },
    /// List available checkpoints
    List {
        /// Dataset directory
        dataset: PathBuf,
        /// Output format (text, json)
        #[arg(short, long, default_value = "text")]
        format: String,
    },
    /// Recover to a specific point in time
    RecoverTimestamp {
        /// Dataset directory
        dataset: PathBuf,
        /// Target timestamp (ISO 8601 format: 2024-01-01T12:00:00Z)
        timestamp: String,
        /// Output directory for recovered data
        output: PathBuf,
    },
    /// Recover to a specific transaction ID
    RecoverTransaction {
        /// Dataset directory
        dataset: PathBuf,
        /// Target transaction ID
        transaction_id: u64,
        /// Output directory for recovered data
        output: PathBuf,
    },
    /// Archive transaction logs
    Archive {
        /// Dataset directory
        dataset: PathBuf,
    },
}

/// Benchmark actions for performance testing and dataset generation
#[derive(Subcommand)]
pub enum BenchmarkAction {
    /// Run benchmark suite on a dataset
    Run {
        /// Target dataset (alphanumeric, _, - only; no dots or extensions)
        dataset: String,
        /// Benchmark suite (sp2bench, watdiv, ldbc, bsbm, custom)
        #[arg(short, long, default_value = "sp2bench")]
        suite: String,
        /// Number of iterations
        #[arg(short = 'I', long, default_value = "10")]
        iterations: usize,
        /// Output report file
        #[arg(short, long)]
        output: Option<PathBuf>,
        /// Enable detailed timing information
        #[arg(long)]
        detailed: bool,
        /// Warmup iterations before benchmarking
        #[arg(long, default_value = "3")]
        warmup: usize,
    },
    /// Generate synthetic benchmark datasets
    Generate {
        /// Output dataset path
        output: PathBuf,
        /// Dataset size (tiny, small, medium, large, xlarge)
        #[arg(short, long, default_value = "small")]
        size: String,
        /// Dataset type (rdf, graph, semantic)
        #[arg(short = 't', long, default_value = "rdf")]
        dataset_type: String,
        /// Random seed for reproducibility
        #[arg(long)]
        seed: Option<u64>,
        /// Number of triples to generate
        #[arg(long)]
        triples: Option<usize>,
        /// Schema file for constrained generation
        #[arg(long)]
        schema: Option<PathBuf>,
    },
    /// Analyze query workload from log files
    Analyze {
        /// Query log file or dataset
        input: PathBuf,
        /// Output analysis report
        #[arg(short, long)]
        output: Option<PathBuf>,
        /// Report format (text, json, html)
        #[arg(short, long, default_value = "text")]
        format: String,
        /// Include query optimization suggestions
        #[arg(long)]
        suggestions: bool,
        /// Analyze patterns and frequencies
        #[arg(long)]
        patterns: bool,
    },
    /// Compare benchmark results for regression detection
    Compare {
        /// Baseline benchmark results file
        baseline: PathBuf,
        /// Current benchmark results file
        current: PathBuf,
        /// Output comparison report
        #[arg(short, long)]
        output: Option<PathBuf>,
        /// Regression threshold percentage
        #[arg(long, default_value = "10.0")]
        threshold: f64,
        /// Report format (text, json, html)
        #[arg(short, long, default_value = "text")]
        format: String,
    },
}

/// SAMM Aspect Model actions (Java ESMF SDK compatible)
#[derive(Subcommand)]
pub enum AspectAction {
    /// Validate a SAMM Aspect model
    Validate {
        /// Aspect model file (Turtle format)
        file: PathBuf,
        /// Show detailed validation output
        #[arg(short, long)]
        detailed: bool,
        /// Output format (text, json)
        #[arg(short, long, default_value = "text")]
        format: String,
    },
    /// Pretty-print an Aspect model
    Prettyprint {
        /// Aspect model file (Turtle format)
        file: PathBuf,
        /// Output file (stdout if not specified)
        #[arg(short, long)]
        output: Option<PathBuf>,
        /// Output format (turtle, rdfxml, jsonld)
        #[arg(short, long, default_value = "turtle")]
        format: String,
        /// Include comments
        #[arg(long)]
        comments: bool,
    },
    /// Generate artifacts from Aspect model
    To {
        /// Aspect model file (Turtle format)
        file: PathBuf,
        /// Target format (rust, python, java, scala, typescript, graphql, markdown, html,
        /// jsonschema, openapi, asyncapi, jsonld, payload, aas, sql, diagram)
        format: String,
        /// Output file or directory
        #[arg(short, long)]
        output: Option<PathBuf>,
        /// Include examples in output
        #[arg(long)]
        examples: bool,
        /// Format variant (for aas: xml/json/aasx, for sql: postgresql/mysql/sqlite,
        /// for diagram: dot/svg/png)
        #[arg(short = 'f', long = "format")]
        format_variant: Option<String>,
    },
    /// Edit Aspect model (move elements or create new version)
    Edit {
        #[command(subcommand)]
        action: EditAction,
    },
    /// Show where model elements are used
    Usage {
        /// Aspect model file or URN
        input: String,
        /// Models root directory (required when using URN)
        #[arg(long = "models-root")]
        models_root: Option<PathBuf>,
    },
    /// Convert DTDL to SAMM Aspect model
    From {
        /// DTDL Interface file (JSON format)
        file: PathBuf,
        /// Output file (Turtle format)
        #[arg(short, long)]
        output: Option<PathBuf>,
        /// Output format (ttl, json, xml)
        #[arg(short, long, default_value = "ttl")]
        format: String,
    },
}

/// Edit actions for Aspect models (Java ESMF SDK compatible)
#[derive(Subcommand)]
pub enum EditAction {
    /// Move element to different namespace
    Move {
        /// Aspect model file (Turtle format)
        file: PathBuf,
        /// Element URN to move
        element: String,
        /// Target namespace (optional)
        namespace: Option<String>,
        /// Don't write changes, only show report
        #[arg(long)]
        dry_run: bool,
        /// Include detailed content changes (with --dry-run)
        #[arg(long)]
        details: bool,
        /// Overwrite existing files
        #[arg(long)]
        force: bool,
        /// Copy file header from source
        #[arg(long)]
        copy_file_header: bool,
    },
    /// Create new version of Aspect model
    Newversion {
        /// Aspect model file (Turtle format)
        file: PathBuf,
        /// Update major version
        #[arg(long, conflicts_with_all = ["minor", "micro"])]
        major: bool,
        /// Update minor version
        #[arg(long, conflicts_with_all = ["major", "micro"])]
        minor: bool,
        /// Update micro version
        #[arg(long, conflicts_with_all = ["major", "minor"])]
        micro: bool,
        /// Don't write changes, only show report
        #[arg(long)]
        dry_run: bool,
        /// Include detailed content changes (with --dry-run)
        #[arg(long)]
        details: bool,
        /// Overwrite existing files
        #[arg(long)]
        force: bool,
    },
}

/// Asset Administration Shell (AAS) actions (Java ESMF SDK compatible)
#[derive(Subcommand)]
pub enum AasAction {
    /// Convert AAS Submodel Templates to Aspect Models
    ToAspect {
        /// AAS file (XML, JSON, or AASX format)
        file: PathBuf,
        /// Output directory for generated Aspect Models
        #[arg(short = 'd', long = "output-directory")]
        output_directory: Option<PathBuf>,
        /// Select specific submodel template(s) to convert (repeatable)
        #[arg(short = 's', long = "submodel-template")]
        submodel_templates: Vec<usize>,
    },
    /// List submodel templates in AAS file
    List {
        /// AAS file (XML, JSON, or AASX format)
        file: PathBuf,
    },
}

/// Package management actions (Java ESMF SDK compatible)
#[derive(Subcommand)]
pub enum PackageAction {
    /// Import namespace package (ZIP)
    Import {
        /// Namespace package ZIP file
        file: PathBuf,
        /// Directory to import into (required)
        #[arg(long = "models-root", required = true)]
        models_root: PathBuf,
        /// Don't write changes, print report only
        #[arg(long)]
        dry_run: bool,
        /// Include details about model content changes (with --dry-run)
        #[arg(long)]
        details: bool,
        /// Overwrite existing files
        #[arg(long)]
        force: bool,
    },
    /// Export Aspect Model or namespace as ZIP package
    Export {
        /// Aspect Model file or namespace URN
        input: String,
        /// Output ZIP file path (required)
        #[arg(short = 'o', long = "output", required = true)]
        output: PathBuf,
        /// Namespace version filter (for URN exports)
        #[arg(long)]
        version: Option<String>,
    },
}

// === Phase D: Industrial Connectivity CLI Actions (0.1.0) ===

/// Time-series database operations
#[derive(Subcommand)]
pub enum TsdbAction {
    /// Query time-series data with SPARQL temporal extensions
    Query {
        /// Dataset name
        dataset: String,
        /// Series ID to query
        #[arg(short = 'S', long)]
        series: Option<u64>,
        /// Start time (ISO 8601 format)
        #[arg(long)]
        start: Option<String>,
        /// End time (ISO 8601 format)
        #[arg(long)]
        end: Option<String>,
        /// SPARQL query with temporal functions (ts:window, ts:resample, ts:interpolate)
        #[arg(long)]
        sparql: Option<String>,
        /// Aggregation function (avg, min, max, sum, count)
        #[arg(short, long)]
        aggregate: Option<String>,
        /// Output format (table, json, csv)
        #[arg(short = 'f', long, default_value = "table")]
        format: String,
    },
    /// Insert time-series data points
    Insert {
        /// Dataset name
        dataset: String,
        /// Series ID
        #[arg(short, long)]
        series: u64,
        /// Timestamp (ISO 8601 format, default: now)
        #[arg(short, long)]
        timestamp: Option<String>,
        /// Value to insert
        #[arg(short = 'V', long)]
        value: f64,
        /// Batch insert from CSV file (columns: timestamp,value)
        #[arg(long)]
        from_csv: Option<PathBuf>,
    },
    /// Show compression statistics
    Stats {
        /// Dataset name
        dataset: String,
        /// Series ID (all series if omitted)
        #[arg(short, long)]
        series: Option<u64>,
        /// Show detailed statistics
        #[arg(long)]
        detailed: bool,
    },
    /// Compact time-series storage
    Compact {
        /// Dataset name
        dataset: String,
        /// Series ID (all series if omitted)
        #[arg(short, long)]
        series: Option<u64>,
        /// Force compaction even if not needed
        #[arg(long)]
        force: bool,
    },
    /// Manage retention policies
    Retention {
        #[command(subcommand)]
        action: RetentionAction,
    },
    /// Export time-series to CSV or Parquet
    Export {
        /// Dataset name
        dataset: String,
        /// Series ID
        #[arg(short, long)]
        series: u64,
        /// Output file path
        #[arg(short, long)]
        output: PathBuf,
        /// Export format (csv, parquet)
        #[arg(short, long, default_value = "csv")]
        format: String,
        /// Start time (ISO 8601 format)
        #[arg(long)]
        start: Option<String>,
        /// End time (ISO 8601 format)
        #[arg(long)]
        end: Option<String>,
    },
    /// Benchmark time-series performance
    Benchmark {
        /// Dataset name
        dataset: String,
        /// Number of data points to write
        #[arg(long, default_value = "100000")]
        points: usize,
        /// Number of series to create
        #[arg(long, default_value = "1")]
        series_count: usize,
    },
}

/// Retention policy management
#[derive(Subcommand)]
pub enum RetentionAction {
    /// List retention policies
    List {
        /// Dataset name
        dataset: String,
    },
    /// Add retention policy
    Add {
        /// Dataset name
        dataset: String,
        /// Policy name
        #[arg(short, long)]
        name: String,
        /// Retention duration (e.g., 7d, 90d, 1y)
        #[arg(short, long)]
        duration: String,
        /// Downsampling resolution (e.g., 1m, 1h, 1d)
        #[arg(long)]
        downsample: Option<String>,
        /// Downsampling aggregation (avg, min, max, sum, first, last)
        #[arg(long, default_value = "avg")]
        aggregation: String,
    },
    /// Remove retention policy
    Remove {
        /// Dataset name
        dataset: String,
        /// Policy name
        #[arg(short, long)]
        name: String,
    },
    /// Run retention enforcement manually
    Enforce {
        /// Dataset name
        dataset: String,
        /// Dry run (show what would be deleted)
        #[arg(long)]
        dry_run: bool,
    },
}

/// Modbus protocol operations
#[derive(Subcommand)]
pub enum ModbusAction {
    /// Monitor Modbus TCP device
    MonitorTcp {
        /// Device IP address and port (e.g., 192.168.1.100:502)
        #[arg(short, long)]
        address: String,
        /// Modbus unit ID
        #[arg(short, long, default_value = "1")]
        unit_id: u8,
        /// Register start address
        #[arg(long)]
        start: u16,
        /// Number of registers to read
        #[arg(long, default_value = "10")]
        count: u16,
        /// Polling interval in milliseconds
        #[arg(long, default_value = "1000")]
        interval: u64,
        /// Output format (table, json, csv)
        #[arg(short, long, default_value = "table")]
        format: String,
        /// Output to file instead of stdout
        #[arg(short, long)]
        output: Option<PathBuf>,
    },
    /// Monitor Modbus RTU device (serial)
    MonitorRtu {
        /// Serial port (e.g., /dev/ttyUSB0, COM3)
        #[arg(short, long)]
        port: String,
        /// Baud rate
        #[arg(short, long, default_value = "9600")]
        baud: u32,
        /// Modbus unit ID
        #[arg(short, long, default_value = "1")]
        unit_id: u8,
        /// Register start address
        #[arg(long)]
        start: u16,
        /// Number of registers to read
        #[arg(long, default_value = "10")]
        count: u16,
        /// Polling interval in milliseconds
        #[arg(long, default_value = "1000")]
        interval: u64,
    },
    /// Read Modbus registers
    Read {
        /// Device configuration (TCP address or RTU port)
        #[arg(short, long)]
        device: String,
        /// Register type (holding, input, coil, discrete)
        #[arg(short = 't', long, default_value = "holding")]
        register_type: String,
        /// Register start address
        #[arg(long)]
        address: u16,
        /// Number of registers to read
        #[arg(long, default_value = "1")]
        count: u16,
        /// Data type interpretation (int16, uint16, int32, uint32, float32, bit)
        #[arg(long)]
        datatype: Option<String>,
    },
    /// Write Modbus registers
    Write {
        /// Device configuration (TCP address or RTU port)
        #[arg(short, long)]
        device: String,
        /// Register address
        #[arg(long)]
        address: u16,
        /// Value to write
        #[arg(long)]
        value: String,
        /// Data type (int16, uint16, int32, uint32, float32)
        #[arg(long, default_value = "uint16")]
        datatype: String,
    },
    /// Generate RDF triples from Modbus data
    ToRdf {
        /// Device configuration (TCP address or RTU port)
        #[arg(short, long)]
        device: String,
        /// Register mapping configuration file (TOML)
        #[arg(short = 'C', long)]
        config: PathBuf,
        /// Output RDF file
        #[arg(short, long)]
        output: PathBuf,
        /// RDF format (turtle, ntriples, jsonld)
        #[arg(short, long, default_value = "turtle")]
        format: String,
        /// Number of readings to collect
        #[arg(short = 'n', long, default_value = "1")]
        count: usize,
    },
    /// Start Modbus mock server for testing
    MockServer {
        /// Server port
        #[arg(short, long, default_value = "5020")]
        port: u16,
        /// Mock data configuration file
        #[arg(short = 'C', long)]
        config: Option<PathBuf>,
    },
}

/// CANbus protocol operations
#[derive(Subcommand)]
pub enum CanbusAction {
    /// Monitor CAN interface
    Monitor {
        /// CAN interface name (e.g., can0, vcan0)
        #[arg(short = 'I', long)]
        interface: String,
        /// Filter by CAN ID (decimal or hex with 0x prefix)
        #[arg(long)]
        filter: Option<String>,
        /// DBC file for signal decoding
        #[arg(long)]
        dbc: Option<PathBuf>,
        /// Output format (table, json, csv)
        #[arg(short, long, default_value = "table")]
        format: String,
        /// Output to file instead of stdout
        #[arg(short, long)]
        output: Option<PathBuf>,
        /// Show only J1939 messages
        #[arg(long)]
        j1939: bool,
    },
    /// Parse DBC file
    ParseDbc {
        /// DBC file path (Vector CANdb++ format)
        #[arg(short = 'd', long)]
        file: PathBuf,
        /// Output format (json, yaml, table)
        #[arg(short = 'f', long, default_value = "table")]
        format: String,
        /// Show detailed signal information
        #[arg(long)]
        detailed: bool,
    },
    /// Decode CAN frame using DBC
    Decode {
        /// CAN ID (decimal or hex with 0x prefix)
        #[arg(long)]
        id: String,
        /// CAN data (hex bytes, e.g., DEADBEEF)
        #[arg(long)]
        data: String,
        /// DBC file for decoding
        #[arg(long)]
        dbc: PathBuf,
        /// Output format (table, json)
        #[arg(short, long, default_value = "table")]
        format: String,
    },
    /// Send CAN frame
    Send {
        /// CAN interface name (e.g., can0, vcan0)
        #[arg(short = 'I', long)]
        interface: String,
        /// CAN ID (decimal or hex with 0x prefix)
        #[arg(long)]
        id: String,
        /// CAN data (hex bytes, e.g., DEADBEEF)
        #[arg(long)]
        data: String,
        /// Extended frame (29-bit ID)
        #[arg(long)]
        extended: bool,
    },
    /// Generate SAMM Aspect Model from DBC
    ToSamm {
        /// DBC file path
        #[arg(short, long)]
        dbc: PathBuf,
        /// Output directory for Aspect Models
        #[arg(short, long)]
        output: PathBuf,
        /// Base namespace URI
        #[arg(long, default_value = "urn:samm:org.example.can")]
        namespace: String,
        /// Generate separate Aspect per message
        #[arg(long)]
        per_message: bool,
    },
    /// Generate RDF triples from CAN data
    ToRdf {
        /// CAN interface name
        #[arg(short = 'I', long)]
        interface: String,
        /// DBC file for signal mapping
        #[arg(long)]
        dbc: PathBuf,
        /// Output RDF file
        #[arg(short, long)]
        output: PathBuf,
        /// RDF format (turtle, ntriples, jsonld)
        #[arg(short, long, default_value = "turtle")]
        format: String,
        /// Number of frames to collect
        #[arg(short = 'n', long, default_value = "100")]
        count: usize,
    },
    /// Replay CAN log file
    Replay {
        /// CAN log file (candump format)
        #[arg(short, long)]
        file: PathBuf,
        /// CAN interface to replay on
        #[arg(short = 'I', long)]
        interface: String,
        /// Playback speed multiplier
        #[arg(long, default_value = "1.0")]
        speed: f64,
        /// Loop playback
        #[arg(long)]
        r#loop: bool,
    },
}

/// Query profiler actions
#[derive(Subcommand)]
pub enum ProfilerAction {
    /// Profile a SPARQL query with latency statistics
    Run {
        /// Dataset name or path
        #[arg(short, long)]
        dataset: String,
        /// SPARQL query string or file path
        #[arg(short = 'Q', long)]
        query: String,
        /// Treat query as a file path
        #[arg(long)]
        file: bool,
        /// Number of profiling iterations
        #[arg(short = 'I', long, default_value = "10")]
        iterations: usize,
        /// Show optimization suggestions
        #[arg(long)]
        suggestions: bool,
    },
    /// Show optimization suggestions for a query
    Suggest {
        /// SPARQL query string or file path
        #[arg(short = 'Q', long)]
        query: String,
        /// Treat query as a file path
        #[arg(long)]
        file: bool,
    },
}

/// Result cache management actions
#[derive(Subcommand)]
pub enum ResultCacheAction {
    /// Show cache statistics
    Stats,
    /// Clear all cache entries
    Clear,
    /// Invalidate cache entries for a dataset
    Invalidate {
        /// Dataset name
        #[arg(short, long)]
        dataset: String,
    },
    /// Evict expired cache entries
    Evict,
    /// List cache entries
    List {
        /// Filter by dataset name
        #[arg(short, long)]
        dataset: Option<String>,
    },
    /// Configure cache settings
    Config {
        /// Maximum cache entries
        #[arg(long)]
        max_size: Option<usize>,
        /// Default TTL in seconds
        #[arg(long)]
        ttl: Option<u64>,
    },
}

/// Stream processing actions
#[derive(Subcommand)]
pub enum StreamAction {
    /// Stream SPARQL query results
    Query {
        /// Dataset name or path
        #[arg(short, long)]
        dataset: String,
        /// SPARQL query string or file path
        #[arg(short = 'Q', long)]
        query: String,
        /// Treat query as a file path
        #[arg(long)]
        file: bool,
        /// Chunk size (rows per chunk)
        #[arg(long, default_value = "1000")]
        chunk_size: usize,
        /// Output format (json, csv, tsv, table)
        #[arg(short, long, default_value = "json")]
        format: String,
        /// Maximum rows to stream
        #[arg(long)]
        max_rows: Option<usize>,
        /// Disable progress indicator
        #[arg(long)]
        no_progress: bool,
        /// Output file path (default: stdout)
        #[arg(short, long)]
        output: Option<PathBuf>,
    },
}