@outfitter/cli 0.2.0 → 0.3.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 +24 -0
- package/dist/cli.js +1 -1
- package/dist/command.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/output.d.ts +2 -2
- package/dist/output.js +4 -2
- package/dist/shared/@outfitter/{cli-efy6jfcj.js → cli-4h4rpdra.js} +1 -0
- package/dist/shared/@outfitter/{cli-8gg0hck1.js → cli-7wp5nj0s.js} +16 -12
- package/dist/shared/@outfitter/{cli-72kg550t.d.ts → cli-e6yv2764.d.ts} +29 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -367,10 +367,34 @@ if (flags.reset) {
|
|
|
367
367
|
|
|
368
368
|
| Variable | Description | Default |
|
|
369
369
|
|----------|-------------|---------|
|
|
370
|
+
| `OUTFITTER_ENV` | Environment profile (`development`, `production`, `test`) | `production` |
|
|
371
|
+
| `OUTFITTER_VERBOSE` | Override verbose mode (`1` or `0`) | - |
|
|
370
372
|
| `OUTFITTER_JSON` | Set to `1` to force JSON output | - |
|
|
371
373
|
| `OUTFITTER_JSONL` | Set to `1` to force JSONL output (takes priority over JSON) | - |
|
|
372
374
|
| `XDG_STATE_HOME` | State directory for pagination | Platform-specific |
|
|
373
375
|
|
|
376
|
+
### `resolveVerbose(verbose?)`
|
|
377
|
+
|
|
378
|
+
Resolve verbose mode from environment configuration. Use this instead of hardcoding verbosity so your CLI responds to `OUTFITTER_ENV` and `OUTFITTER_VERBOSE` automatically.
|
|
379
|
+
|
|
380
|
+
**Precedence** (highest wins):
|
|
381
|
+
1. `OUTFITTER_VERBOSE` environment variable (`"1"` or `"0"`)
|
|
382
|
+
2. Explicit `verbose` parameter (from `--verbose` CLI flag)
|
|
383
|
+
3. `OUTFITTER_ENV` profile defaults (`true` in development)
|
|
384
|
+
4. `false` (default)
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
import { resolveVerbose } from "@outfitter/cli/output";
|
|
388
|
+
|
|
389
|
+
const isVerbose = resolveVerbose();
|
|
390
|
+
// With OUTFITTER_ENV=development → true
|
|
391
|
+
// With OUTFITTER_VERBOSE=0 → false (overrides everything)
|
|
392
|
+
// With nothing set → false
|
|
393
|
+
|
|
394
|
+
// Pass through from CLI flag
|
|
395
|
+
const isVerbose = resolveVerbose(cliFlags.verbose);
|
|
396
|
+
```
|
|
397
|
+
|
|
374
398
|
### Output Mode Priority
|
|
375
399
|
|
|
376
400
|
1. Explicit `mode` option in `output()` call
|
package/dist/cli.js
CHANGED
package/dist/command.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./shared/@outfitter/cli-qz47jk6d";
|
|
2
2
|
import { ANSI, Theme, Tokens, createTheme } from "./shared/@outfitter/cli-ykxn7rb2";
|
|
3
|
-
import { output } from "./shared/@outfitter/cli-
|
|
3
|
+
import { output } from "./shared/@outfitter/cli-e6yv2764";
|
|
4
4
|
import { OutputMode } from "./shared/@outfitter/cli-ttt7r0j7";
|
|
5
5
|
export { output, createTheme, Tokens, Theme, OutputMode, ANSI };
|
package/dist/index.js
CHANGED
package/dist/output.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { exitWithError, output } from "./shared/@outfitter/cli-
|
|
1
|
+
import { exitWithError, output, resolveVerbose } from "./shared/@outfitter/cli-e6yv2764";
|
|
2
2
|
import "./shared/@outfitter/cli-ttt7r0j7";
|
|
3
|
-
export { output, exitWithError };
|
|
3
|
+
export { resolveVerbose, output, exitWithError };
|
package/dist/output.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
exitWithError,
|
|
4
|
-
output
|
|
5
|
-
|
|
4
|
+
output,
|
|
5
|
+
resolveVerbose
|
|
6
|
+
} from "./shared/@outfitter/cli-7wp5nj0s.js";
|
|
6
7
|
import"./shared/@outfitter/cli-v1tzwxkt.js";
|
|
7
8
|
export {
|
|
9
|
+
resolveVerbose,
|
|
8
10
|
output,
|
|
9
11
|
exitWithError
|
|
10
12
|
};
|
|
@@ -10,6 +10,7 @@ function createCLI(config) {
|
|
|
10
10
|
if (config.description) {
|
|
11
11
|
program.description(config.description);
|
|
12
12
|
}
|
|
13
|
+
program.option("--json", "Output as JSON", false);
|
|
13
14
|
const exit = config.onExit ?? ((code) => process.exit(code));
|
|
14
15
|
program.exitOverride((error) => {
|
|
15
16
|
if (isCommanderHelp(error)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// packages/cli/src/output.ts
|
|
3
|
+
import { getEnvironment, getEnvironmentDefaults } from "@outfitter/config";
|
|
3
4
|
import {
|
|
4
5
|
safeStringify as contractsSafeStringify,
|
|
5
6
|
exitCodeMap
|
|
@@ -19,14 +20,6 @@ function writeWithBackpressure(stream, data) {
|
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
function getStreamIsTTY(stream) {
|
|
23
|
-
if (!stream)
|
|
24
|
-
return;
|
|
25
|
-
if ("isTTY" in stream) {
|
|
26
|
-
return Boolean(stream.isTTY);
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
23
|
function detectMode(options) {
|
|
31
24
|
if (options?.mode) {
|
|
32
25
|
return options.mode;
|
|
@@ -39,9 +32,7 @@ function detectMode(options) {
|
|
|
39
32
|
return "json";
|
|
40
33
|
if (envJsonl === "0" || envJson === "0")
|
|
41
34
|
return "human";
|
|
42
|
-
|
|
43
|
-
const isTTY = streamIsTTY ?? process.stdout.isTTY;
|
|
44
|
-
return isTTY ? "human" : "json";
|
|
35
|
+
return "human";
|
|
45
36
|
}
|
|
46
37
|
function isValidCategory(category) {
|
|
47
38
|
return category in exitCodeMap;
|
|
@@ -161,5 +152,18 @@ function exitWithError(error, options) {
|
|
|
161
152
|
}
|
|
162
153
|
process.exit(exitCode);
|
|
163
154
|
}
|
|
155
|
+
function resolveVerbose(verbose) {
|
|
156
|
+
const envVerbose = process.env["OUTFITTER_VERBOSE"];
|
|
157
|
+
if (envVerbose === "1")
|
|
158
|
+
return true;
|
|
159
|
+
if (envVerbose === "0")
|
|
160
|
+
return false;
|
|
161
|
+
if (verbose !== undefined) {
|
|
162
|
+
return verbose;
|
|
163
|
+
}
|
|
164
|
+
const env = getEnvironment();
|
|
165
|
+
const defaults = getEnvironmentDefaults(env);
|
|
166
|
+
return defaults.verbose;
|
|
167
|
+
}
|
|
164
168
|
|
|
165
|
-
export { output, exitWithError };
|
|
169
|
+
export { output, exitWithError, resolveVerbose };
|
|
@@ -50,4 +50,32 @@ declare function output(data: unknown, options?: OutputOptions): Promise<void>;
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
declare function exitWithError(error: Error, options?: OutputOptions): never;
|
|
53
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Resolve verbose mode from environment configuration.
|
|
55
|
+
*
|
|
56
|
+
* Precedence (highest wins):
|
|
57
|
+
* 1. `OUTFITTER_VERBOSE` environment variable (`"1"` or `"0"`)
|
|
58
|
+
* 2. Explicit `verbose` parameter (from CLI flag)
|
|
59
|
+
* 3. `OUTFITTER_ENV` environment profile defaults
|
|
60
|
+
* 4. `false` (default)
|
|
61
|
+
*
|
|
62
|
+
* @param verbose - Optional explicit verbose flag (e.g. from --verbose CLI flag)
|
|
63
|
+
* @returns Whether verbose mode is enabled
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import { resolveVerbose } from "@outfitter/cli/output";
|
|
68
|
+
*
|
|
69
|
+
* // Auto-resolve from environment
|
|
70
|
+
* const isVerbose = resolveVerbose();
|
|
71
|
+
*
|
|
72
|
+
* // With OUTFITTER_ENV=development → true
|
|
73
|
+
* // With OUTFITTER_VERBOSE=0 → false (overrides everything)
|
|
74
|
+
* // With nothing set → false
|
|
75
|
+
*
|
|
76
|
+
* // From CLI flag
|
|
77
|
+
* const isVerbose = resolveVerbose(cliFlags.verbose);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
declare function resolveVerbose(verbose?: boolean): boolean;
|
|
81
|
+
export { output, exitWithError, resolveVerbose };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outfitter/cli",
|
|
3
3
|
"description": "Typed CLI runtime with terminal detection, rendering, output contracts, and input parsing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -269,7 +269,7 @@
|
|
|
269
269
|
},
|
|
270
270
|
"dependencies": {
|
|
271
271
|
"@clack/prompts": "^0.11.0",
|
|
272
|
-
"@outfitter/config": "0.
|
|
272
|
+
"@outfitter/config": "0.3.0",
|
|
273
273
|
"@outfitter/contracts": "0.2.0",
|
|
274
274
|
"@outfitter/types": "0.2.0",
|
|
275
275
|
"better-result": "^2.5.1",
|