-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.rs
More file actions
1018 lines (822 loc) · 30.9 KB
/
command.rs
File metadata and controls
1018 lines (822 loc) · 30.9 KB
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
use clap::Subcommand;
#[derive(Subcommand)]
pub enum Commands {
/// Authenticate or manage auth settings
Auth {
#[command(subcommand)]
command: Option<AuthCommands>,
},
/// Derived views — virtual SQL tables built from queries over your data
Datasets {
/// Dataset ID to show details
id: Option<String>,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
/// Output format (used with dataset ID)
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
#[command(subcommand)]
command: Option<DatasetsCommands>,
},
/// Execute a SQL query, or check status of a running query
Query {
/// SQL query string (omit when using a subcommand)
sql: Option<String>,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w')]
workspace_id: Option<String>,
/// Scope query to a specific connection
#[arg(long)]
connection: Option<String>,
/// Run query against a specific managed database (overrides the current database set via `databases set`)
#[arg(long, short = 'd')]
database: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "csv"])]
output: String,
#[command(subcommand)]
command: Option<QueryCommands>,
},
/// Manage workspaces
Workspaces {
#[command(subcommand)]
command: WorkspaceCommands,
},
/// Manage workspace connections
Connections {
/// Connection ID to show details
id: Option<String>,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
/// Output format (used with connection ID)
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
#[command(subcommand)]
command: Option<ConnectionsCommands>,
},
/// Managed databases you create and populate with tables (parquet uploads)
Databases {
/// Database id or description (omit to use a subcommand)
name_or_id: Option<String>,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
#[command(subcommand)]
command: Option<DatabasesCommands>,
},
/// Manage tables in a workspace
Tables {
#[command(subcommand)]
command: TablesCommands,
},
/// Manage the hotdata agent skill
Skills {
#[command(subcommand)]
command: SkillCommands,
},
/// Retrieve a stored query result by ID, or list recent results
Results {
/// Result ID (omit to use a subcommand)
result_id: Option<String>,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "csv"])]
output: String,
#[command(subcommand)]
command: Option<ResultsCommands>,
},
/// Manage background jobs
Jobs {
/// Job ID (omit to use a subcommand)
id: Option<String>,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
/// Output format (used with job ID)
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
#[command(subcommand)]
command: Option<JobsCommands>,
},
/// Manage indexes on a table
Indexes {
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
#[command(subcommand)]
command: IndexesCommands,
},
/// Manage embedding providers (OpenAI, local, etc.) used by vector indexes
#[command(name = "embedding-providers")]
EmbeddingProviders {
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
#[command(subcommand)]
command: EmbeddingProvidersCommands,
},
/// Full-text or vector search across a table column
Search {
/// Search query text — required for both --type bm25 and --type vector
query: String,
/// Search type (`bm25` or `vector`). Inferred automatically when the table has exactly
/// one search index — required only when multiple indexes exist.
///
/// `vector` runs server-side `vector_distance(col, 'text')` — the server resolves the
/// embedding column, model, and metric from the index metadata.
///
/// `bm25` runs server-side `bm25_search(table, col, 'text')` and requires a BM25 index
/// on the column.
#[arg(long, value_parser = ["vector", "bm25"])]
r#type: Option<String>,
/// Table to search (`connection.table` or `connection.schema.table`).
/// Schema defaults to `public` when omitted.
#[arg(long)]
table: String,
/// Column to search. Inferred automatically when the table has exactly one search index
/// of the resolved type — required only when multiple indexed columns exist.
/// For `--type vector`, name the source text column — the server resolves the embedding
/// column from the index metadata.
#[arg(long)]
column: Option<String>,
/// Columns to display (comma-separated, defaults to all)
#[arg(long)]
select: Option<String>,
/// Maximum number of results
#[arg(long, default_value = "10")]
limit: u32,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w')]
workspace_id: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "csv"])]
output: String,
},
/// Inspect query run history
Queries {
/// Query run ID to show details
id: Option<String>,
/// Output format (used with query run ID)
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
#[command(subcommand)]
command: Option<QueriesCommands>,
},
/// Manage sandboxes
Sandbox {
/// Sandbox ID to show details
id: Option<String>,
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
#[command(subcommand)]
command: Option<SandboxCommands>,
},
/// Sync database context with local Markdown (`./<NAME>.md` in the current directory)
Context {
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w', global = true)]
workspace_id: Option<String>,
/// Database ID (defaults to active database set via 'hotdata databases set')
#[arg(long, short = 'd', global = true)]
database_id: Option<String>,
#[command(subcommand)]
command: ContextCommands,
},
/// Generate shell completions
Completions {
/// Shell to generate completions for
#[arg(value_enum)]
shell: ShellChoice,
},
/// Update the hotdata CLI to the latest release
Update,
}
#[derive(Clone, clap::ValueEnum)]
pub enum ShellChoice {
Bash,
Zsh,
Fish,
}
impl From<ShellChoice> for clap_complete::Shell {
fn from(s: ShellChoice) -> Self {
match s {
ShellChoice::Bash => clap_complete::Shell::Bash,
ShellChoice::Zsh => clap_complete::Shell::Zsh,
ShellChoice::Fish => clap_complete::Shell::Fish,
}
}
}
#[derive(Subcommand)]
pub enum QueryCommands {
/// Check the status of a running query and retrieve results.
/// Exit codes: 0 = succeeded, 1 = failed, 2 = still running (poll again)
Status {
/// Query run ID
id: String,
},
}
#[derive(Subcommand)]
pub enum AuthCommands {
/// Log in via browser (same as `hotdata auth` with no subcommand)
Login,
/// Create a new account via browser (defaults to GitHub OAuth)
Register {
/// Sign up with email and password instead of GitHub
#[arg(long)]
email: bool,
},
/// Remove authentication for a profile
Logout,
/// Show authentication status
Status,
}
#[derive(Subcommand)]
pub enum IndexesCommands {
/// List indexes (defaults to the whole workspace; narrow with filters or pass --dataset-id)
List {
/// Filter by connection ID
#[arg(long, short = 'c', conflicts_with = "dataset_id")]
connection_id: Option<String>,
/// Filter by schema name
#[arg(long, conflicts_with = "dataset_id")]
schema: Option<String>,
/// Filter by table name
#[arg(long, conflicts_with = "dataset_id")]
table: Option<String>,
/// List indexes for a specific dataset (alternative scope to --connection-id)
#[arg(long)]
dataset_id: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Create an index on a table or dataset.
///
/// For connection-scoped indexes, pass the table and columns using bracket notation:
/// `connection.table[col1,col2]` or `connection.schema.table[col1,col2]`
/// (schema defaults to `public` when omitted)
///
/// For dataset-scoped indexes, use `--dataset-id` with `--columns`.
Create {
/// Table and columns to index: `connection.table[col1,col2]`
/// or `connection.schema.table[col1,col2]`. Schema defaults to `public`.
///
/// Quote the argument to prevent shell glob expansion:
/// `hotdata indexes create 'airbnb.listings[description]' --type bm25`
#[arg(conflicts_with = "dataset_id")]
target: Option<String>,
/// Dataset ID (alternative scope to the positional target)
#[arg(long, conflicts_with = "target")]
dataset_id: Option<String>,
/// Columns to index (comma-separated). Required with --dataset-id;
/// for connection scope use bracket notation in the target instead.
#[arg(long)]
columns: Option<String>,
/// Index name (derived from table, columns, and type if omitted)
#[arg(long)]
name: Option<String>,
/// Index type — required (no default; choose deliberately)
#[arg(long, value_parser = ["sorted", "bm25", "vector"])]
r#type: String,
/// Distance metric for vector indexes
#[arg(long, value_parser = ["l2", "cosine", "dot"])]
metric: Option<String>,
/// Create as a background job
#[arg(long)]
r#async: bool,
/// Embedding provider ID — when set on a vector index over a text column,
/// embeddings are generated automatically. Defaults to first system provider if omitted.
#[arg(long = "embedding-provider-id")]
embedding_provider_id: Option<String>,
/// Override embedding output dimensions (vector indexes with auto-embedding only)
#[arg(long)]
dimensions: Option<u32>,
/// Custom name for the generated embedding column (defaults to `{column}_embedding`)
#[arg(long = "output-column")]
output_column: Option<String>,
/// Human-readable description of the embedding (e.g. "product titles")
#[arg(long)]
description: Option<String>,
},
/// Delete an index from a table or dataset
///
/// Pass either connection scope (--connection-id + --schema + --table) OR
/// dataset scope (--dataset-id), not both.
Delete {
/// Connection ID (use with --schema and --table)
#[arg(long, short = 'c', conflicts_with = "dataset_id", requires_all = ["schema", "table"])]
connection_id: Option<String>,
/// Schema name (requires --connection-id)
#[arg(long, requires = "connection_id")]
schema: Option<String>,
/// Table name (requires --connection-id)
#[arg(long, requires = "connection_id")]
table: Option<String>,
/// Dataset ID (alternative scope to --connection-id)
#[arg(long, conflicts_with_all = ["connection_id", "schema", "table"])]
dataset_id: Option<String>,
/// Index name
#[arg(long)]
name: String,
},
}
#[derive(Subcommand)]
pub enum JobsCommands {
/// List background jobs (shows active jobs by default)
List {
/// Filter by job type
#[arg(long, value_parser = ["data_refresh_table", "data_refresh_connection", "dataset_refresh", "create_index", "create_dataset_index"])]
job_type: Option<String>,
/// Filter by status
#[arg(long, value_parser = ["pending", "running", "succeeded", "partially_succeeded", "failed"])]
status: Option<String>,
/// Show all jobs, not just active ones
#[arg(long)]
all: bool,
/// Maximum number of results (default: 50)
#[arg(long)]
limit: Option<u32>,
/// Pagination offset
#[arg(long)]
offset: Option<u32>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
}
#[derive(Subcommand)]
pub enum DatasetsCommands {
/// List all datasets in a workspace
List {
/// Maximum number of results (default: 100, max: 1000)
#[arg(long)]
limit: Option<u32>,
/// Pagination offset
#[arg(long)]
offset: Option<u32>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Create a derived view from a SQL query or saved query
Create {
/// SQL table name the dataset is addressable as (e.g. my_view)
#[arg(long)]
name: String,
/// Human-readable display label
#[arg(long)]
description: Option<String>,
/// SQL query to create the dataset from
#[arg(long, conflicts_with = "query_id", required_unless_present = "query_id")]
sql: Option<String>,
/// Saved query ID to create the dataset from
#[arg(long, conflicts_with = "sql", required_unless_present = "sql")]
query_id: Option<String>,
},
/// Update a dataset's description and/or name
Update {
/// Dataset ID
id: String,
/// New display label
#[arg(long)]
description: Option<String>,
/// New SQL table name (must be a valid identifier)
#[arg(long)]
name: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Refresh a dataset by re-running its source (URL fetch or saved query) and creating a new version
Refresh {
/// Dataset ID
id: String,
/// Submit as a background job
#[arg(long)]
r#async: bool,
},
}
#[derive(Subcommand)]
pub enum WorkspaceCommands {
/// List all workspaces
List {
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Set the default workspace
Set {
/// Workspace ID to set as default (omit for interactive selection)
workspace_id: Option<String>,
},
}
#[derive(Subcommand)]
pub enum ConnectionsCreateCommands {
/// List available connection types, or get details for a specific type
List {
/// Connection type name (e.g. postgres, mysql); omit to list all
name: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
}
#[derive(Subcommand)]
pub enum DatabasesCommands {
/// List managed databases in the workspace
List {
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Show details for a specific managed database
Show {
/// Database name or ID
name_or_id: String,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Create a new managed database
Create {
/// Optional display label (not unique, not an identifier — databases are addressed by id)
#[arg(long)]
description: Option<String>,
/// Schema for tables declared at create time (default: public)
#[arg(long, default_value = "public")]
schema: String,
/// Table to declare up front (repeatable)
#[arg(long = "table")]
tables: Vec<String>,
/// When the database expires. Accepts a relative duration (e.g. 24h, 7d, 90m)
/// or an RFC 3339 timestamp. Defaults to 24h when omitted.
#[arg(long)]
expires_at: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Set the current database (used by default when no database is specified)
Set {
/// Database id or description
id_or_description: String,
},
/// Delete a managed database and its tables
Delete {
/// Database name or connection ID
name_or_id: String,
},
/// Load a parquet file into a table using dot notation: `database.table` or `database.schema.table`
Load {
/// Table to load into: `database.table` or `database.schema.table`.
/// Schema defaults to `public` when omitted.
target: String,
/// Path to a local parquet file to upload and load
#[arg(long, conflicts_with_all = ["upload_id", "url"])]
file: Option<String>,
/// URL of a remote parquet file to download and load
#[arg(long, conflicts_with_all = ["file", "upload_id"])]
url: Option<String>,
/// Use a previously staged upload ID from `POST /v1/files` instead of uploading
#[arg(long, conflicts_with_all = ["file", "url"])]
upload_id: Option<String>,
},
/// Manage tables inside a managed database
Tables {
/// Database id or description — shorthand for `tables list` when no subcommand is given
database: Option<String>,
#[command(subcommand)]
command: Option<DatabaseTablesCommands>,
},
}
#[derive(Subcommand)]
pub enum DatabaseTablesCommands {
/// List tables in a managed database
List {
/// Database id or description (defaults to current database)
#[arg(long)]
database: Option<String>,
/// Filter by schema name
#[arg(long)]
schema: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Load a parquet file into a table (creates or replaces the table)
Load {
/// Database id or description (defaults to current database)
#[arg(long)]
database: Option<String>,
/// Table name
table: String,
/// Schema name (default: public)
#[arg(long, default_value = "public")]
schema: String,
/// Path to a local parquet file to upload and load
#[arg(long, conflicts_with_all = ["upload_id", "url"])]
file: Option<String>,
/// URL of a remote parquet file to download and load
#[arg(long, conflicts_with_all = ["file", "upload_id"])]
url: Option<String>,
/// Use a previously staged upload ID from `POST /v1/files` instead of uploading
#[arg(long, conflicts_with_all = ["file", "url"])]
upload_id: Option<String>,
},
/// Delete a table from a managed database
Delete {
/// Database id or description (defaults to current database)
#[arg(long)]
database: Option<String>,
/// Table name
table: String,
/// Schema name (default: public)
#[arg(long, default_value = "public")]
schema: String,
},
}
#[derive(Subcommand)]
pub enum ConnectionsCommands {
/// Interactively create a new connection
New,
/// List all connections for a workspace
List {
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Create a new connection, or list/inspect available connection types
Create {
#[command(subcommand)]
command: Option<ConnectionsCreateCommands>,
/// Connection name
#[arg(long)]
name: Option<String>,
/// Connection source type (e.g. postgres, mysql, snowflake)
#[arg(long = "type")]
source_type: Option<String>,
/// Connection config as a JSON object
#[arg(long)]
config: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Refresh a connection's schema or data
Refresh {
/// Connection ID
connection_id: String,
/// Refresh data instead of schema metadata
#[arg(long)]
data: bool,
/// Narrow refresh to a specific schema (requires --table for data refresh)
#[arg(long)]
schema: Option<String>,
/// Narrow refresh to a specific table (requires --schema)
#[arg(long)]
table: Option<String>,
/// Submit as a background job (only valid with --data)
#[arg(long)]
r#async: bool,
/// Include uncached tables in connection-wide data refresh (only with --data, no --table)
#[arg(long = "include-uncached")]
include_uncached: bool,
},
}
#[derive(Subcommand)]
pub enum SkillCommands {
/// Install or update the hotdata skill into agent directories
Install {
/// Install into the current project directory instead of globally
#[arg(long)]
project: bool,
},
/// Show the installation status of the hotdata skill
Status,
/// List installed skills and their versions (alias for status)
List,
}
#[derive(Subcommand)]
pub enum ResultsCommands {
/// List stored query results
List {
/// Maximum number of results (default: 100, max: 1000)
#[arg(long)]
limit: Option<u32>,
/// Pagination offset
#[arg(long)]
offset: Option<u32>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
}
#[derive(Subcommand)]
pub enum QueriesCommands {
/// List query runs
List {
/// Maximum number of results
#[arg(long, default_value_t = 20)]
limit: u32,
/// Pagination cursor from a previous response
#[arg(long)]
cursor: Option<String>,
/// Filter by status (comma-separated, e.g. running,failed)
#[arg(long)]
status: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
}
#[derive(Subcommand)]
pub enum SandboxCommands {
/// List all sandboxes in a workspace
List {
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Create a new sandbox and set it as active
New {
/// Sandbox name
#[arg(long)]
name: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Update a sandbox's markdown or name
Update {
/// Sandbox ID (defaults to active sandbox)
id: Option<String>,
/// New sandbox name
#[arg(long)]
name: Option<String>,
/// Markdown content
#[arg(long)]
markdown: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Print the markdown content of the current sandbox
Read,
/// Set the active sandbox (omit ID to clear)
Set {
/// Sandbox ID to set as active (omit to clear)
id: Option<String>,
},
/// Run a command inside a hotdata sandbox. Creates a new sandbox unless an ID was provided.
/// Example: hotdata sandbox run claude
/// Example: hotdata sandbox <id> run claude
Run {
/// Sandbox name (only used when creating a new sandbox)
#[arg(long)]
name: Option<String>,
/// Command and arguments to execute
#[arg(trailing_var_arg = true, required = true)]
cmd: Vec<String>,
},
}
#[derive(Subcommand)]
pub enum ContextCommands {
/// List named contexts in the workspace
List {
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
/// Only include names starting with this prefix (case-sensitive)
#[arg(long)]
prefix: Option<String>,
},
/// Print context content to stdout
Show {
/// Context name (same rules as a SQL table identifier; local file is <NAME>.md). A trailing `.md` is ignored (e.g. `USER.md` → `USER`).
name: String,
},
/// Download context from the database to ./<NAME>.md
Pull {
/// Context name (trailing `.md` ignored, e.g. `USER.md` → `USER`)
name: String,
/// Overwrite ./<NAME>.md if it already exists
#[arg(long)]
force: bool,
/// Print the target path and size only; do not write a file
#[arg(long)]
dry_run: bool,
},
/// Upload ./<NAME>.md to the database as named context
Push {
/// Context name (trailing `.md` ignored, e.g. `USER.md` → `USER`; reads `./USER.md`)
name: String,
/// Print what would be sent; do not POST
#[arg(long)]
dry_run: bool,
},
}
#[derive(Subcommand)]
pub enum TablesCommands {
/// List all tables in a workspace
List {
/// Workspace ID (defaults to first workspace from login)
#[arg(long, short = 'w')]
workspace_id: Option<String>,
/// Filter by connection ID (also enables column output)
#[arg(long, short = 'c')]
connection_id: Option<String>,
/// Filter by schema name (supports % wildcards)
#[arg(long)]
schema: Option<String>,
/// Filter by table name (supports % wildcards)
#[arg(long)]
table: Option<String>,
/// Maximum number of results to return
#[arg(long)]
limit: Option<u32>,
/// Pagination cursor from a previous response
#[arg(long)]
cursor: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
}
#[derive(Subcommand)]
pub enum EmbeddingProvidersCommands {
/// List embedding providers
List {
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Show details for a specific embedding provider
Get {
/// Provider ID
id: String,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Create a new embedding provider
Create {
/// Provider name (must be unique within the workspace)
#[arg(long)]
name: String,
/// Provider type ("local" or "service")
#[arg(long, value_parser = ["local", "service"])]
provider_type: String,
/// Provider-specific config as a JSON string (model, base_url, dimensions, etc.)
#[arg(long)]
config: Option<String>,
/// The provider's own API key (e.g. an OpenAI sk-... key). Auto-creates a
/// managed secret. Mutually exclusive with --secret-name. Named
/// `--provider-api-key` to pair with `--provider-type` and to avoid colliding
/// with the global `--api-key` (Hotdata auth) flag.
#[arg(long = "provider-api-key", conflicts_with = "secret_name")]
provider_api_key: Option<String>,
/// Reference an existing secret by name (for service providers)
#[arg(long)]
secret_name: Option<String>,
/// Output format
#[arg(long = "output", short = 'o', default_value = "table", value_parser = ["table", "json", "yaml"])]
output: String,
},
/// Update an embedding provider's name, config, or secret
Update {
/// Provider ID
id: String,
/// New name
#[arg(long)]
name: Option<String>,
/// New config as a JSON string
#[arg(long)]
config: Option<String>,
/// New provider API key (replaces or creates the managed secret).
/// See `embedding-providers create --provider-api-key` for naming rationale.