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
//! VantaDB CLI Arguments - Shareable definitions for CLI binary and build.rs
//!
//! Exposes the struct definitions and command enums required for parsing.
use clap::{Parser, Subcommand, ValueEnum};
/// VantaDB CLI - Embedded persistent memory and vector retrieval engine
#[derive(Parser, Debug)]
#[command(name = "vanta-cli")]
#[command(author = "VantaDB Team")]
#[command(version = env!("CARGO_PKG_VERSION"))]
#[command(about = "CLI for interacting with VantaDB", long_about = None)]
pub struct Cli {
/// Path to the database directory. Defaults to the value of the VANTA_DB environment variable, or './db' if neither is set.
#[arg(short, long, env = "VANTA_DB", default_value = "./db", global = true)]
pub db: String,
/// Enable verbose output
#[arg(short, long, global = true)]
pub verbose: bool,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug, Clone)]
pub enum Commands {
/// Save a key-value pair to persistent memory
Put {
/// Namespace for the key
#[arg(long)]
namespace: String,
/// Key to store the value under
#[arg(long)]
key: String,
/// Value to store (payload text)
#[arg(long)]
payload: String,
/// Optional vector embedding (comma-separated f32 values)
#[arg(long)]
vector: Option<String>,
},
/// Retrieve a value from persistent memory
Get {
/// Namespace for the key
#[arg(long)]
namespace: String,
/// Key to retrieve the value for
#[arg(long)]
key: String,
},
/// List keys and values in a namespace
List {
/// Namespace to list
#[arg(long)]
namespace: String,
/// Maximum number of records to return
#[arg(long, default_value = "100")]
limit: usize,
},
/// Rebuild all database indexes (HNSW, text index, derived indexes)
RebuildIndex,
/// Validate text index integrity without repairing
AuditIndex {
/// Optional namespace to audit (audits all if not specified)
#[arg(long)]
namespace: Option<String>,
/// Output results as JSON
#[arg(long)]
json: bool,
/// Perform deep structural validation
#[arg(long)]
deep: bool,
},
/// Repair text index if inconsistencies are detected
RepairTextIndex,
/// Export records to a JSON file
Export {
/// Optional namespace to export (exports all if not specified)
#[arg(long)]
namespace: Option<String>,
/// Output file path
#[arg(long)]
out: String,
},
/// Import records from a JSON file
Import {
/// Input file path
#[arg(long, name = "in")]
input: String,
},
/// Execute a structured query (IQL/hybrid)
Query {
/// Query string
query: String,
/// Maximum results to return
#[arg(long, default_value = "10")]
limit: usize,
},
/// Display database health diagnostics and system status
Status,
/// Generate shell completion scripts
Completions {
/// Shell type for the completion script
#[arg(long, value_enum)]
shell: Shell,
},
/// Search records semantically across a namespace
Search {
/// Namespace to search within
#[arg(long)]
namespace: String,
/// Text query for semantic/hybrid search
#[arg(long)]
query: String,
/// Maximum number of results
#[arg(long, default_value = "10")]
limit: usize,
},
/// Delete a record by namespace and key
Delete {
/// Namespace of the record
#[arg(long)]
namespace: String,
/// Key of the record to delete
#[arg(long)]
key: String,
},
/// Manage namespaces
#[command(subcommand)]
Namespace(NamespaceCommand),
/// Start the HTTP or MCP server wrapper
Server {
/// Start HTTP server wrapper (default)
#[arg(long)]
http: bool,
/// Start MCP server wrapper over stdio
#[arg(long)]
mcp: bool,
/// Port for the HTTP server
#[arg(long, short, env = "VANTADB_PORT")]
port: Option<u16>,
/// Host for the HTTP server
#[arg(long, env = "VANTADB_HOST")]
host: Option<String>,
},
}
#[derive(Subcommand, Debug, Clone)]
pub enum NamespaceCommand {
/// List all namespaces
List,
/// Show record count and details for a namespace
Info {
/// Namespace to inspect
namespace: String,
},
}
#[derive(ValueEnum, Clone, Copy, Debug, PartialEq, Eq)]
#[allow(clippy::enum_variant_names)]
pub enum Shell {
Bash,
Zsh,
Fish,
#[value(name = "powershell", alias = "power-shell")]
PowerShell,
}
impl From<Shell> for clap_complete::Shell {
fn from(shell: Shell) -> Self {
match shell {
Shell::Bash => clap_complete::Shell::Bash,
Shell::Zsh => clap_complete::Shell::Zsh,
Shell::Fish => clap_complete::Shell::Fish,
Shell::PowerShell => clap_complete::Shell::PowerShell,
}
}
}