You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add global CLI options and environment variable support (#5)
Add --no-color, --quiet, --mode/--live/--sandbox flags and env var
support for --json (MEMBERSTACK_JSON) and --mode (MEMBERSTACK_MODE).
Replaces the boolean --live flag with a --mode <mode> option while
maintaining backwards compatibility via --live and --sandbox shorthands.
Disables cli-table3 ANSI codes when color is off. Updates docs and adds
comprehensive tests.
Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
Copy file name to clipboardExpand all lines: ARCHITECTURE.md
+12-6Lines changed: 12 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,10 @@ memberstack-cli/
50
50
│ └── core/ # Core library tests
51
51
│ ├── auth.test.ts
52
52
│ ├── graphql-client.test.ts
53
+
│ ├── no-color.test.ts
53
54
│ ├── oauth.test.ts
55
+
│ ├── program-options.test.ts
56
+
│ ├── quiet.test.ts
54
57
│ └── utils.test.ts
55
58
│
56
59
├── dist/ # Compiled output (ESM)
@@ -64,14 +67,17 @@ memberstack-cli/
64
67
65
68
### Entry Point (`src/index.ts`)
66
69
67
-
Prints the ASCII banner to stderr, registers all command groups on the shared `program` instance, and calls `parseAsync()`.
70
+
Propagates `--no-color` / `NO_COLOR` to all color libraries before imports, conditionally prints the ASCII banner (suppressed by `--quiet`), registers all command groups on the shared `program` instance, and calls `parseAsync()`.
68
71
69
72
### Program (`src/lib/program.ts`)
70
73
71
-
A shared Commander instance with two global options:
74
+
A shared Commander instance with global options:
72
75
73
-
-`--json` — output raw JSON instead of formatted tables
74
-
-`--live` — use live environment instead of sandbox (appended as `?mode=live` or `?mode=sandbox` to the GraphQL URL)
76
+
-`-j, --json` — output raw JSON instead of formatted tables (env: `MEMBERSTACK_JSON`)
77
+
-`-q, --quiet` — suppress banner and non-essential output
78
+
-`--no-color` — disable color output (respects the `NO_COLOR` standard)
79
+
-`--mode <mode>` — set environment mode: `sandbox` (default) or `live` (env: `MEMBERSTACK_MODE`)
80
+
-`--live` / `--sandbox` — shorthands for `--mode live` and `--mode sandbox`
75
81
76
82
### Commands (`src/commands/`)
77
83
@@ -118,7 +124,7 @@ Tokens are stored in `~/.memberstack/auth.json` with restrictive file permission
118
124
-`printTable()` — renders data as a `cli-table3` table to stderr (or JSON to stdout with `--json`)
119
125
-`printRecord()` — renders a single object as a vertical key-value table
120
126
-`printJson()` — writes raw JSON to stdout
121
-
-`printSuccess()` / `printError()` — colored status messages to stderr
127
+
-`printSuccess()` / `printError()` — colored status messages to stderr (`printSuccess` is suppressed by `--quiet`)
122
128
-`parseKeyValuePairs()` — parses `key=value` strings for `--data` options
123
129
-`parseWhereClause()` — parses `field operator value` filter syntax for `--where`
124
130
-`parseJsonString()` — parses raw JSON strings for `--query`
@@ -154,7 +160,7 @@ All user-facing output (tables, spinners, messages) goes to **stderr**. JSON out
154
160
|`open`| Opens browser for OAuth login |
155
161
|`papaparse`| CSV parsing and generation |
156
162
157
-
Dev: `tsup` (bundler), `typescript`, `vitest` (tests), `biome` via `ultracite` (lint/format).
0 commit comments