axiodb 15.1.0 → 16.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/cli/VERSION +1 -0
- package/cli/cmd/collection.go +169 -0
- package/cli/cmd/connect.go +597 -0
- package/cli/cmd/db.go +171 -0
- package/cli/cmd/document.go +376 -0
- package/cli/cmd/index.go +101 -0
- package/cli/cmd/ping.go +36 -0
- package/cli/cmd/root.go +36 -0
- package/cli/cmd/version.go +41 -0
- package/cli/go.mod +15 -0
- package/cli/go.sum +20 -0
- package/cli/internal/config/config.go +111 -0
- package/cli/main.go +7 -0
- package/cli/pkg/commands/collection.go +68 -0
- package/cli/pkg/commands/db.go +62 -0
- package/cli/pkg/commands/document.go +184 -0
- package/cli/pkg/commands/index.go +51 -0
- package/cli/pkg/protocol/auth.go +46 -0
- package/cli/pkg/protocol/client.go +174 -0
- package/cli/pkg/protocol/message.go +75 -0
- package/opencode.json +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
- [Simple: connect without authentication](#simple-connect-without-authentication)
|
|
31
31
|
- [Advanced: TCP authentication](#advanced-tcp-authentication)
|
|
32
32
|
- [Advanced: TLS encryption](#advanced-tls-encryption)
|
|
33
|
+
- [AxioDB CLI — Command Line Interface](#-axiodb-cli--command-line-interface)
|
|
33
34
|
- [Troubleshooting](#-troubleshooting)
|
|
34
35
|
- [Docker Deployment](#-docker-deployment)
|
|
35
36
|
- [Simple: run the container](#simple-run-the-container)
|
|
@@ -338,6 +339,79 @@ The rule: the `-e AXIODB_TLS_CERT_PATH=...` value must always match the *right-h
|
|
|
338
339
|
|
|
339
340
|
---
|
|
340
341
|
|
|
342
|
+
## 💻 AxioDB CLI — Command Line Interface
|
|
343
|
+
|
|
344
|
+
A Go-based CLI tool for interacting with AxioDB servers via the TCP protocol. Supports all database operations with both single-command and interactive REPL modes.
|
|
345
|
+
|
|
346
|
+
### Quick Install
|
|
347
|
+
|
|
348
|
+
**Linux/macOS:**
|
|
349
|
+
```bash
|
|
350
|
+
curl -fsSL https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/install.sh | bash
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Windows (PowerShell):**
|
|
354
|
+
```powershell
|
|
355
|
+
irm https://raw.githubusercontent.com/nexoral/AxioDB/main/cli/Scripts/install.ps1 | iex
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Or download directly:** [GitHub Releases](https://github.com/nexoral/AxioDB/releases?q=cli-v&expanded=true)
|
|
359
|
+
|
|
360
|
+
### Supported Platforms
|
|
361
|
+
|
|
362
|
+
| OS | Architectures |
|
|
363
|
+
|------|--------------|
|
|
364
|
+
| Linux | amd64, arm64, 386, armv7 |
|
|
365
|
+
| macOS | amd64 (Intel), arm64 (Apple Silicon) |
|
|
366
|
+
| Windows | amd64, arm64, 386 |
|
|
367
|
+
| FreeBSD | amd64 |
|
|
368
|
+
| OpenBSD | amd64 |
|
|
369
|
+
| NetBSD | amd64 |
|
|
370
|
+
|
|
371
|
+
### Usage
|
|
372
|
+
|
|
373
|
+
**Single commands:**
|
|
374
|
+
```bash
|
|
375
|
+
axiodb -c axiodb://127.0.0.1:27019 ping
|
|
376
|
+
axiodb -c axiodb://127.0.0.1:27019 db list
|
|
377
|
+
axiodb -c axiodb://127.0.0.1:27019 document insert '{"name":"Alice"}' --db mydb --collection users
|
|
378
|
+
axiodb -c axiodb://127.0.0.1:27019 document query '{}' --db mydb --collection users
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**Interactive REPL (MongoDB shell style):**
|
|
382
|
+
```bash
|
|
383
|
+
axiodb connect
|
|
384
|
+
# axiodb> use mydb
|
|
385
|
+
# axiodb:mydb> show collections
|
|
386
|
+
# axiodb:mydb> use mydb.users
|
|
387
|
+
# axiodb:mydb:users> db.users.find({})
|
|
388
|
+
# axiodb:mydb:users> db.users.insert({name: "Bob"})
|
|
389
|
+
# axiodb:mydb:users> exit
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
**With authentication:**
|
|
393
|
+
```bash
|
|
394
|
+
axiodb -c axiodb://127.0.0.1:27019 -u admin -p admin connect
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
**With TLS:**
|
|
398
|
+
```bash
|
|
399
|
+
axiodb -c axiodb://127.0.0.1:27019 --tls --tls-cert ./cert.pem connect
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Features
|
|
403
|
+
|
|
404
|
+
- **All 21 TCP commands:** database, collection, document CRUD, aggregation, indexing
|
|
405
|
+
- **Interactive REPL:** MongoDB shell syntax (`use`, `show dbs`, `db.coll.find()`)
|
|
406
|
+
- **TLS support:** `--tls`, `--tls-cert`, `--tls-skip-verify`
|
|
407
|
+
- **Auth support:** `-u` / `-p` flags
|
|
408
|
+
- **JSON output:** `--output json` for scripting
|
|
409
|
+
- **Tab autocomplete** in REPL mode
|
|
410
|
+
|
|
411
|
+
👉 **[Full CLI Documentation](https://github.com/nexoral/AxioDB/tree/main/cli)**
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
341
415
|
## 🔧 Troubleshooting
|
|
342
416
|
|
|
343
417
|
### "Not connected to server" right after calling `connect()`
|
package/cli/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
16.2.1
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
package cmd
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
|
|
6
|
+
"github.com/nexoral/axiodb-cli/internal/config"
|
|
7
|
+
"github.com/nexoral/axiodb-cli/pkg/commands"
|
|
8
|
+
"github.com/nexoral/axiodb-cli/pkg/protocol"
|
|
9
|
+
"github.com/spf13/cobra"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
var collectionCmd = &cobra.Command{
|
|
13
|
+
Use: "collection",
|
|
14
|
+
Short: "Collection operations",
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
var collectionCreateCmd = &cobra.Command{
|
|
18
|
+
Use: "create <name>",
|
|
19
|
+
Short: "Create a collection",
|
|
20
|
+
Args: cobra.ExactArgs(1),
|
|
21
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
22
|
+
cfg, err := config.FromFlags(cmd)
|
|
23
|
+
if err != nil {
|
|
24
|
+
return err
|
|
25
|
+
}
|
|
26
|
+
if cfg.DB == "" {
|
|
27
|
+
return fmt.Errorf("--db flag is required")
|
|
28
|
+
}
|
|
29
|
+
client, err := cfg.ConnectAndAuth()
|
|
30
|
+
if err != nil {
|
|
31
|
+
return err
|
|
32
|
+
}
|
|
33
|
+
defer client.Disconnect()
|
|
34
|
+
|
|
35
|
+
resp, err := commands.CreateCollection(client, cfg.DB, args[0])
|
|
36
|
+
if err != nil {
|
|
37
|
+
return err
|
|
38
|
+
}
|
|
39
|
+
return printOutput(cfg.Output, resp)
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var collectionDeleteCmd = &cobra.Command{
|
|
44
|
+
Use: "delete <name>",
|
|
45
|
+
Short: "Delete a collection",
|
|
46
|
+
Args: cobra.ExactArgs(1),
|
|
47
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
48
|
+
cfg, err := config.FromFlags(cmd)
|
|
49
|
+
if err != nil {
|
|
50
|
+
return err
|
|
51
|
+
}
|
|
52
|
+
if cfg.DB == "" {
|
|
53
|
+
return fmt.Errorf("--db flag is required")
|
|
54
|
+
}
|
|
55
|
+
client, err := cfg.ConnectAndAuth()
|
|
56
|
+
if err != nil {
|
|
57
|
+
return err
|
|
58
|
+
}
|
|
59
|
+
defer client.Disconnect()
|
|
60
|
+
|
|
61
|
+
resp, err := commands.DeleteCollection(client, cfg.DB, args[0])
|
|
62
|
+
if err != nil {
|
|
63
|
+
return err
|
|
64
|
+
}
|
|
65
|
+
return printOutput(cfg.Output, resp)
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var collectionExistsCmd = &cobra.Command{
|
|
70
|
+
Use: "exists <name>",
|
|
71
|
+
Short: "Check if a collection exists",
|
|
72
|
+
Args: cobra.ExactArgs(1),
|
|
73
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
74
|
+
cfg, err := config.FromFlags(cmd)
|
|
75
|
+
if err != nil {
|
|
76
|
+
return err
|
|
77
|
+
}
|
|
78
|
+
if cfg.DB == "" {
|
|
79
|
+
return fmt.Errorf("--db flag is required")
|
|
80
|
+
}
|
|
81
|
+
client, err := cfg.ConnectAndAuth()
|
|
82
|
+
if err != nil {
|
|
83
|
+
return err
|
|
84
|
+
}
|
|
85
|
+
defer client.Disconnect()
|
|
86
|
+
|
|
87
|
+
exists, err := commands.CollectionExists(client, cfg.DB, args[0])
|
|
88
|
+
if err != nil {
|
|
89
|
+
return err
|
|
90
|
+
}
|
|
91
|
+
fmt.Printf("Collection '%s' exists: %v\n", args[0], exists)
|
|
92
|
+
return nil
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var collectionInfoCmd = &cobra.Command{
|
|
97
|
+
Use: "info",
|
|
98
|
+
Short: "Get collection information",
|
|
99
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
100
|
+
cfg, err := config.FromFlags(cmd)
|
|
101
|
+
if err != nil {
|
|
102
|
+
return err
|
|
103
|
+
}
|
|
104
|
+
if cfg.DB == "" {
|
|
105
|
+
return fmt.Errorf("--db flag is required")
|
|
106
|
+
}
|
|
107
|
+
client, err := cfg.ConnectAndAuth()
|
|
108
|
+
if err != nil {
|
|
109
|
+
return err
|
|
110
|
+
}
|
|
111
|
+
defer client.Disconnect()
|
|
112
|
+
|
|
113
|
+
resp, err := commands.GetCollectionInfo(client, cfg.DB)
|
|
114
|
+
if err != nil {
|
|
115
|
+
return err
|
|
116
|
+
}
|
|
117
|
+
return printOutput(cfg.Output, resp)
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var collectionListCmd = &cobra.Command{
|
|
122
|
+
Use: "list",
|
|
123
|
+
Short: "List all collections in a database",
|
|
124
|
+
RunE: func(cmd *cobra.Command, args []string) error {
|
|
125
|
+
cfg, err := config.FromFlags(cmd)
|
|
126
|
+
if err != nil {
|
|
127
|
+
return err
|
|
128
|
+
}
|
|
129
|
+
if cfg.DB == "" {
|
|
130
|
+
return fmt.Errorf("--db flag is required")
|
|
131
|
+
}
|
|
132
|
+
client, err := cfg.ConnectAndAuth()
|
|
133
|
+
if err != nil {
|
|
134
|
+
return err
|
|
135
|
+
}
|
|
136
|
+
defer client.Disconnect()
|
|
137
|
+
|
|
138
|
+
resp, err := commands.GetCollectionInfo(client, cfg.DB)
|
|
139
|
+
if err != nil {
|
|
140
|
+
return err
|
|
141
|
+
}
|
|
142
|
+
return printOutput(cfg.Output, resp)
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
func init() {
|
|
147
|
+
collectionCmd.AddCommand(collectionCreateCmd)
|
|
148
|
+
collectionCmd.AddCommand(collectionDeleteCmd)
|
|
149
|
+
collectionCmd.AddCommand(collectionExistsCmd)
|
|
150
|
+
collectionCmd.AddCommand(collectionInfoCmd)
|
|
151
|
+
collectionCmd.AddCommand(collectionListCmd)
|
|
152
|
+
rootCmd.AddCommand(collectionCmd)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
func createCollection(client *protocol.Client, dbName, collName string) (*protocol.Response, error) {
|
|
156
|
+
return commands.CreateCollection(client, dbName, collName)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
func deleteCollection(client *protocol.Client, dbName, collName string) (*protocol.Response, error) {
|
|
160
|
+
return commands.DeleteCollection(client, dbName, collName)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
func collectionExists(client *protocol.Client, dbName, collName string) (bool, error) {
|
|
164
|
+
return commands.CollectionExists(client, dbName, collName)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
func getCollectionInfo(client *protocol.Client, dbName string) (*protocol.Response, error) {
|
|
168
|
+
return commands.GetCollectionInfo(client, dbName)
|
|
169
|
+
}
|