@1sat/cli 0.0.76 → 0.0.77
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 +6 -0
- package/package.json +4 -4
- package/src/args.ts +22 -2
- package/src/cli.ts +20 -0
- package/src/help.ts +6 -0
package/README.md
CHANGED
|
@@ -72,6 +72,12 @@ export PRIVATE_KEY_WIF="<your WIF key>"
|
|
|
72
72
|
1sat wallet balance
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
**Env file** (same keys as above; file values override the process environment for this run):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
1sat --env-file mint.env wallet balance
|
|
79
|
+
```
|
|
80
|
+
|
|
75
81
|
**Encrypted keyfile (interactive use):**
|
|
76
82
|
|
|
77
83
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.77",
|
|
4
4
|
"description": "CLI for 1Sat Ordinals SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/cli.ts",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
],
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@1sat/actions": "0.0.
|
|
29
|
+
"@1sat/actions": "0.0.184",
|
|
30
30
|
"@1sat/client": "0.0.42",
|
|
31
|
-
"@1sat/types": "0.0.
|
|
31
|
+
"@1sat/types": "0.0.34",
|
|
32
32
|
"@1sat/wallet-node": "0.0.57",
|
|
33
33
|
"@1sat/wallet-server": "0.0.26",
|
|
34
|
-
"@bsv/sdk": "^2.
|
|
34
|
+
"@bsv/sdk": "^2.1.6",
|
|
35
35
|
"@bsv/wallet-toolbox": "2.1.24",
|
|
36
36
|
"chalk": "^5.0.0",
|
|
37
37
|
"@clack/prompts": "^0.8.0",
|
package/src/args.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface GlobalFlags {
|
|
|
9
9
|
quiet: boolean
|
|
10
10
|
yes: boolean
|
|
11
11
|
chain: 'main' | 'test'
|
|
12
|
+
/** Paths from `--env-file` / `--env-file=path` (may be empty). */
|
|
13
|
+
envFiles: string[]
|
|
12
14
|
help: boolean
|
|
13
15
|
version: boolean
|
|
14
16
|
rest: string[]
|
|
@@ -24,6 +26,7 @@ export function parseGlobalFlags(args: string[]): GlobalFlags {
|
|
|
24
26
|
let chain: 'main' | 'test' = 'main'
|
|
25
27
|
let help = false
|
|
26
28
|
let version = false
|
|
29
|
+
const envFiles: string[] = []
|
|
27
30
|
const rest: string[] = []
|
|
28
31
|
const skip = new Set<number>()
|
|
29
32
|
|
|
@@ -56,6 +59,15 @@ export function parseGlobalFlags(args: string[]): GlobalFlags {
|
|
|
56
59
|
}
|
|
57
60
|
break
|
|
58
61
|
}
|
|
62
|
+
case '--env-file': {
|
|
63
|
+
const value = args[i + 1]
|
|
64
|
+
if (!value || value.startsWith('-')) {
|
|
65
|
+
throw new Error('--env-file requires a path')
|
|
66
|
+
}
|
|
67
|
+
envFiles.push(value)
|
|
68
|
+
skip.add(i + 1)
|
|
69
|
+
break
|
|
70
|
+
}
|
|
59
71
|
case '--help':
|
|
60
72
|
case '-h':
|
|
61
73
|
help = true
|
|
@@ -65,11 +77,19 @@ export function parseGlobalFlags(args: string[]): GlobalFlags {
|
|
|
65
77
|
version = true
|
|
66
78
|
break
|
|
67
79
|
default:
|
|
68
|
-
|
|
80
|
+
if (arg.startsWith('--env-file=')) {
|
|
81
|
+
const value = arg.slice('--env-file='.length)
|
|
82
|
+
if (!value) {
|
|
83
|
+
throw new Error('--env-file requires a path')
|
|
84
|
+
}
|
|
85
|
+
envFiles.push(value)
|
|
86
|
+
} else {
|
|
87
|
+
rest.push(arg)
|
|
88
|
+
}
|
|
69
89
|
}
|
|
70
90
|
}
|
|
71
91
|
|
|
72
|
-
return { json, quiet, yes, chain, help, version, rest }
|
|
92
|
+
return { json, quiet, yes, chain, envFiles, help, version, rest }
|
|
73
93
|
}
|
|
74
94
|
|
|
75
95
|
/**
|
package/src/cli.ts
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* Pure Bun CLI with manual arg parsing. No frameworks.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { existsSync } from 'node:fs'
|
|
10
|
+
import { resolve } from 'node:path'
|
|
11
|
+
import { config as loadEnv } from 'dotenv'
|
|
9
12
|
import { parseGlobalFlags } from './args'
|
|
10
13
|
import { handleActionCommand } from './commands/action'
|
|
11
14
|
import { handleConfigCommand } from './commands/config'
|
|
@@ -27,8 +30,25 @@ import { formatError } from './output'
|
|
|
27
30
|
|
|
28
31
|
const rawArgs = process.argv.slice(2)
|
|
29
32
|
|
|
33
|
+
/** Load `--env-file` paths into process.env. File values win over existing env. */
|
|
34
|
+
function applyEnvFiles(paths: string[]): void {
|
|
35
|
+
for (const p of paths) {
|
|
36
|
+
const abs = resolve(p)
|
|
37
|
+
if (!existsSync(abs)) {
|
|
38
|
+
throw new Error(`Env file not found: ${p}`)
|
|
39
|
+
}
|
|
40
|
+
const result = loadEnv({ path: abs, quiet: true, override: true })
|
|
41
|
+
if (result.error) {
|
|
42
|
+
throw result.error
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
async function main(): Promise<void> {
|
|
31
48
|
const flags = parseGlobalFlags(rawArgs)
|
|
49
|
+
if (flags.envFiles.length > 0) {
|
|
50
|
+
applyEnvFiles(flags.envFiles)
|
|
51
|
+
}
|
|
32
52
|
|
|
33
53
|
if (flags.version) {
|
|
34
54
|
printVersion()
|
package/src/help.ts
CHANGED
|
@@ -62,6 +62,12 @@ export const GLOBAL_OPTIONS: ArgSpec[] = [
|
|
|
62
62
|
values: '<main|test>',
|
|
63
63
|
description: 'Network (default: main)',
|
|
64
64
|
},
|
|
65
|
+
{
|
|
66
|
+
flag: '--env-file',
|
|
67
|
+
values: '<path>',
|
|
68
|
+
description:
|
|
69
|
+
'Load env vars from a file (repeatable; file values override existing env)',
|
|
70
|
+
},
|
|
65
71
|
{ flag: '--help', description: 'Show help (also -h)' },
|
|
66
72
|
{ flag: '--version', description: 'Show version (also -v)' },
|
|
67
73
|
]
|