@hpx7/delta-pack-cli 0.1.0
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 +159 -0
- package/dist/index.js +10786 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# delta-pack CLI
|
|
2
|
+
|
|
3
|
+
Command-line tool for working with delta-pack schemas and binary data.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @hpx7/delta-pack-cli
|
|
9
|
+
# or
|
|
10
|
+
npx delta-pack <command>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
### generate
|
|
16
|
+
|
|
17
|
+
Generate code from a YAML schema.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
delta-pack generate <schema.yml> -l <language> [-o output]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Flag | Description |
|
|
24
|
+
|------|-------------|
|
|
25
|
+
| `-l, --language <lang>` | Target language: `typescript`/`ts`, `csharp`/`cs` |
|
|
26
|
+
| `-o, --output <file>` | Output file (default: stdout) |
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
```bash
|
|
30
|
+
# Output to stdout
|
|
31
|
+
delta-pack generate schema.yml -l typescript
|
|
32
|
+
|
|
33
|
+
# Output to file
|
|
34
|
+
delta-pack generate schema.yml -l typescript -o generated.ts
|
|
35
|
+
|
|
36
|
+
# Pipe to formatter
|
|
37
|
+
delta-pack generate schema.yml -l ts | prettier --stdin-filepath gen.ts > generated.ts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### encode
|
|
41
|
+
|
|
42
|
+
Encode JSON to binary.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
delta-pack encode <schema.yml> -t <type> [-i input] [-o output]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
| Flag | Description |
|
|
49
|
+
|------|-------------|
|
|
50
|
+
| `-t, --type <name>` | Type name (required) |
|
|
51
|
+
| `-i, --input <file>` | JSON input file (default: stdin) |
|
|
52
|
+
| `-o, --output <file>` | Binary output file (default: stdout) |
|
|
53
|
+
|
|
54
|
+
Examples:
|
|
55
|
+
```bash
|
|
56
|
+
# File to file
|
|
57
|
+
delta-pack encode schema.yml -t Player -i player.json -o player.bin
|
|
58
|
+
|
|
59
|
+
# Stdin to stdout
|
|
60
|
+
cat player.json | delta-pack encode schema.yml -t Player > player.bin
|
|
61
|
+
|
|
62
|
+
# Stdin to file
|
|
63
|
+
delta-pack encode schema.yml -t Player -o player.bin < player.json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### decode
|
|
67
|
+
|
|
68
|
+
Decode binary to JSON.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
delta-pack decode <schema.yml> -t <type> [-i input] [-o output]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| Flag | Description |
|
|
75
|
+
|------|-------------|
|
|
76
|
+
| `-t, --type <name>` | Type name (required) |
|
|
77
|
+
| `-i, --input <file>` | Binary input file (default: stdin) |
|
|
78
|
+
| `-o, --output <file>` | JSON output file (default: stdout) |
|
|
79
|
+
|
|
80
|
+
Examples:
|
|
81
|
+
```bash
|
|
82
|
+
# File to file
|
|
83
|
+
delta-pack decode schema.yml -t Player -i player.bin -o player.json
|
|
84
|
+
|
|
85
|
+
# Stdin to stdout
|
|
86
|
+
cat player.bin | delta-pack decode schema.yml -t Player
|
|
87
|
+
|
|
88
|
+
# Roundtrip
|
|
89
|
+
delta-pack encode schema.yml -t Player -i player.json | delta-pack decode schema.yml -t Player
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### encode-diff
|
|
93
|
+
|
|
94
|
+
Encode the diff between two JSON states to binary.
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
delta-pack encode-diff <schema.yml> -t <type> --old <file> --new <file> [-o output]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
| Flag | Description |
|
|
101
|
+
|------|-------------|
|
|
102
|
+
| `-t, --type <name>` | Type name (required) |
|
|
103
|
+
| `--old <file>` | Old state JSON file (required) |
|
|
104
|
+
| `--new <file>` | New state JSON file (required) |
|
|
105
|
+
| `-o, --output <file>` | Binary output file (default: stdout) |
|
|
106
|
+
|
|
107
|
+
Examples:
|
|
108
|
+
```bash
|
|
109
|
+
# Output to file
|
|
110
|
+
delta-pack encode-diff schema.yml -t GameState --old state1.json --new state2.json -o diff.bin
|
|
111
|
+
|
|
112
|
+
# Output to stdout
|
|
113
|
+
delta-pack encode-diff schema.yml -t GameState --old state1.json --new state2.json > diff.bin
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### decode-diff
|
|
117
|
+
|
|
118
|
+
Apply a binary diff to a JSON state.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
delta-pack decode-diff <schema.yml> -t <type> --old <file> [--diff <file>] [-o output]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
| Flag | Description |
|
|
125
|
+
|------|-------------|
|
|
126
|
+
| `-t, --type <name>` | Type name (required) |
|
|
127
|
+
| `--old <file>` | Old state JSON file (required) |
|
|
128
|
+
| `--diff <file>` | Binary diff file (default: stdin) |
|
|
129
|
+
| `-o, --output <file>` | JSON output file (default: stdout) |
|
|
130
|
+
|
|
131
|
+
Examples:
|
|
132
|
+
```bash
|
|
133
|
+
# File to file
|
|
134
|
+
delta-pack decode-diff schema.yml -t GameState --old state1.json --diff diff.bin -o state2.json
|
|
135
|
+
|
|
136
|
+
# Diff from stdin
|
|
137
|
+
delta-pack encode-diff schema.yml -t GameState --old state1.json --new state2.json | \
|
|
138
|
+
delta-pack decode-diff schema.yml -t GameState --old state1.json
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Exit Codes
|
|
142
|
+
|
|
143
|
+
| Code | Meaning |
|
|
144
|
+
|------|---------|
|
|
145
|
+
| 0 | Success |
|
|
146
|
+
| 1 | Error (invalid arguments, schema error, data validation error) |
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Install dependencies
|
|
152
|
+
bun install
|
|
153
|
+
|
|
154
|
+
# Run tests
|
|
155
|
+
bun test
|
|
156
|
+
|
|
157
|
+
# Run CLI directly
|
|
158
|
+
bun src/index.ts help
|
|
159
|
+
```
|