@nowline/cli 0.0.0-dev.20261013185706.g4498948 → 0.0.0-dev.20261013224238.g0a3e5fc
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/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +2 -1
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/options.d.ts +74 -0
- package/dist/cli/options.d.ts.map +1 -0
- package/dist/cli/options.js +209 -0
- package/dist/cli/options.js.map +1 -0
- package/dist/commands/render.d.ts +2 -2
- package/dist/commands/render.d.ts.map +1 -1
- package/dist/commands/render.js +101 -190
- package/dist/commands/render.js.map +1 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +44 -51
- package/dist/commands/serve.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +2 -2
- package/dist/i18n/locale.d.ts.map +1 -1
- package/dist/i18n/locale.js +2 -5
- package/dist/i18n/locale.js.map +1 -1
- package/dist/io/config.d.ts +1 -1
- package/dist/io/config.d.ts.map +1 -1
- package/dist/io/config.js +1 -1
- package/dist/io/config.js.map +1 -1
- package/man/fr/nowline.1 +21 -3
- package/man/nowline.1 +20 -2
- package/package.json +14 -14
- package/src/cli/help.ts +2 -1
- package/src/cli/options.ts +288 -0
- package/src/commands/render.ts +123 -253
- package/src/commands/serve.ts +44 -62
- package/src/generated/version.ts +2 -2
- package/src/i18n/locale.ts +2 -6
- package/src/io/config.ts +0 -1
- package/dist/cli/non-working.d.ts +0 -10
- package/dist/cli/non-working.d.ts.map +0 -1
- package/dist/cli/non-working.js +0 -20
- package/dist/cli/non-working.js.map +0 -1
- package/dist/cli/theme.d.ts +0 -18
- package/dist/cli/theme.d.ts.map +0 -1
- package/dist/cli/theme.js +0 -43
- package/dist/cli/theme.js.map +0 -1
- package/src/cli/non-working.ts +0 -21
- package/src/cli/theme.ts +0 -47
package/dist/cli/help.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AA4IA,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
package/dist/cli/help.js
CHANGED
|
@@ -75,7 +75,8 @@ RENDER OPTIONS
|
|
|
75
75
|
'default roadmap non-working:' key; omit it to let
|
|
76
76
|
the key apply. Mermaid, MS Project, and XLSX output
|
|
77
77
|
is the same in both views.
|
|
78
|
-
--asset-root <dir> Root for logo / image assets (default:
|
|
78
|
+
--asset-root <dir> Root for logo / image assets (default: the
|
|
79
|
+
.nowlinerc assetRoot key, then the input dir).
|
|
79
80
|
--locale <bcp47> BCP-47 locale (e.g. fr, fr-CA) for CLI message
|
|
80
81
|
output (validator diagnostics, --help, errors).
|
|
81
82
|
Used as a fallback for the rendered drawing only
|
package/dist/cli/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,sEAAsE;AACtE,oEAAoE;AACpE,2DAA2D;AAC3D,MAAM,SAAS,GAAG,WAAW,iBAAiB,EAAE
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,sEAAsE;AACtE,oEAAoE;AACpE,2DAA2D;AAC3D,MAAM,SAAS,GAAG,WAAW,iBAAiB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqI/C,CAAC;AAEF,MAAM,UAAU,UAAU;IACtB,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,aAAa;IACzB,OAAO,GAAG,iBAAiB,EAAE,IAAI,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type NowlineRc, type OptionError, type OptionSpec, type SurfaceOptions } from '@nowline/config';
|
|
2
|
+
import type { ParsedArgs } from './args.js';
|
|
3
|
+
export type PdfOrientation = 'portrait' | 'landscape' | 'auto';
|
|
4
|
+
/** Every option the CLI resolves over its flag and rc layers: the shared five, then its own. */
|
|
5
|
+
export declare const CLI_OPTION_SPECS: Readonly<{
|
|
6
|
+
theme: OptionSpec<import("@nowline/layout").ThemeName>;
|
|
7
|
+
width: OptionSpec<number>;
|
|
8
|
+
now: OptionSpec<Date | null>;
|
|
9
|
+
pageSize: OptionSpec<import("@nowline/export-core").PdfPageSize>;
|
|
10
|
+
nonWorking: OptionSpec<import("@nowline/layout").NonWorkingDisplay>;
|
|
11
|
+
orientation: OptionSpec<PdfOrientation>;
|
|
12
|
+
margin: OptionSpec<number>;
|
|
13
|
+
defaultFormat: OptionSpec<string>;
|
|
14
|
+
fontSans: OptionSpec<string>;
|
|
15
|
+
fontMono: OptionSpec<string>;
|
|
16
|
+
headless: OptionSpec<boolean>;
|
|
17
|
+
useSystemFonts: OptionSpec<boolean>;
|
|
18
|
+
locale: OptionSpec<string>;
|
|
19
|
+
assetRoot: OptionSpec<string>;
|
|
20
|
+
}>;
|
|
21
|
+
type CliSpecs = typeof CLI_OPTION_SPECS;
|
|
22
|
+
export type CliOptionKey = Extract<keyof CliSpecs, string>;
|
|
23
|
+
export interface CliOptions {
|
|
24
|
+
/** Theme, width, now-line date and non-working display; page size when set. */
|
|
25
|
+
surface: SurfaceOptions;
|
|
26
|
+
orientation?: PdfOrientation;
|
|
27
|
+
/** Page margin in points. */
|
|
28
|
+
margin?: number;
|
|
29
|
+
/** The rc `defaultFormat`; the `--format` flag is resolved by `resolveFormat`. */
|
|
30
|
+
defaultFormat?: string;
|
|
31
|
+
fontSans?: string;
|
|
32
|
+
fontMono?: string;
|
|
33
|
+
headless: boolean;
|
|
34
|
+
useSystemFonts: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Where `logo:` assets are read from, as an absolute path: `--asset-root`,
|
|
37
|
+
* else the rc `assetRoot`. Unset means the input file's directory.
|
|
38
|
+
*/
|
|
39
|
+
assetRoot?: string;
|
|
40
|
+
/** The rc `locale`; the flag and `NOWLINE_LOCALE` rank above it (`resolveLocaleOverride`). */
|
|
41
|
+
rcLocale?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Throw the first invalid option as a usage error, in the order the CLI
|
|
44
|
+
* has always reported them: theme, timezone, now, width, non-working.
|
|
45
|
+
*/
|
|
46
|
+
assertValid(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Throw the first invalid PDF setting (page size, orientation, margin).
|
|
49
|
+
* Run after validation, so these errors follow any diagnostics.
|
|
50
|
+
*/
|
|
51
|
+
assertPdfSettingsValid(): void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Resolve the CLI's options over the flag layer, then the `.nowlinerc` layer.
|
|
55
|
+
* `render` and `--serve` both call this, so they read the same keys the same
|
|
56
|
+
* way. `cwd` is what a relative `--asset-root` resolves against (default: the
|
|
57
|
+
* process's). Nothing throws here: a caller reads `defaultFormat` early and reports bad
|
|
58
|
+
* values at the point it always did, through `assertValid`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveCliOptions(args: ParsedArgs, config: NowlineRc | null, context?: {
|
|
61
|
+
rcPath?: string;
|
|
62
|
+
cwd?: string;
|
|
63
|
+
clock?: () => Date;
|
|
64
|
+
}): CliOptions;
|
|
65
|
+
/**
|
|
66
|
+
* An {@link OptionError} in the CLI's wording, naming the flag or `.nowlinerc`
|
|
67
|
+
* key the value came from: `nowline: invalid --width "abc". Must be an integer
|
|
68
|
+
* ≥ 320.` The templates are the ones the CLI used before the schema, so
|
|
69
|
+
* scripts that match them keep working.
|
|
70
|
+
*/
|
|
71
|
+
export declare function formatOptionError(error: OptionError<string>): string;
|
|
72
|
+
export declare function formatChoices(names: readonly string[]): string;
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":"AAQA,OAAO,EAEH,KAAK,SAAS,EACd,KAAK,WAAW,EAGhB,KAAK,UAAU,EAMf,KAAK,cAAc,EACtB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5C,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;AAqC/D,gGAAgG;AAChG,eAAO,MAAM,gBAAgB;;;;;;iBAE4C,UAAU,CAAC,cAAc,CAAC;YACzC,UAAU,CAAC,MAAM,CAAC;mBACL,UAAU,CAAC,MAAM,CAAC;cAC5B,UAAU,CAAC,MAAM,CAAC;cAClB,UAAU,CAAC,MAAM,CAAC;cACb,UAAU,CAAC,OAAO,CAAC;oBACZ,UAAU,CAAC,OAAO,CAAC;YACnC,UAAU,CAAC,MAAM,CAAC;eACzC,UAAU,CAAC,MAAM,CAAC;EAClD,CAAC;AAEH,KAAK,QAAQ,GAAG,OAAO,gBAAgB,CAAC;AACxC,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC,CAAC;AAqB3D,MAAM,WAAW,UAAU;IACvB,+EAA+E;IAC/E,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,IAAI,IAAI,CAAC;IACpB;;;OAGG;IACH,sBAAsB,IAAI,IAAI,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,SAAS,GAAG,IAAI,EACxB,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,GACpE,UAAU,CA2CZ;AA+DD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAcpE;AAcD,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAG9D"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// How the CLI turns flags and `.nowlinerc` keys into render options. The five
|
|
2
|
+
// shared options (theme, width, now, page size, non-working display) come from
|
|
3
|
+
// `@nowline/config`'s schema; the CLI-only keys are registered here as option
|
|
4
|
+
// specs over the same two layers, so adding an rc key is one entry in
|
|
5
|
+
// `CLI_OPTION_SPECS` rather than a hand-written merge in each command
|
|
6
|
+
// (specs/surface-options.md §3.1).
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { ASSET_ROOT_SPEC, rcLayer, resolveOptions, resolveSurfaceOptions, SURFACE_OPTION_SPECS, } from '@nowline/config';
|
|
9
|
+
import { lengthToPoints, parseLength } from '@nowline/export-core';
|
|
10
|
+
import { normalizeZone, TimezoneError } from '@nowline/layout';
|
|
11
|
+
import { CliError, ExitCode } from '../io/exit-codes.js';
|
|
12
|
+
const ORIENTATIONS = ['portrait', 'landscape', 'auto'];
|
|
13
|
+
/** An rc key the CLI reads as a string; any other type is ignored, as it always was. */
|
|
14
|
+
function lenientString(raw) {
|
|
15
|
+
return { ok: true, value: typeof raw === 'string' ? raw : undefined };
|
|
16
|
+
}
|
|
17
|
+
/** An rc or flag switch: only a literal `true` turns it on. */
|
|
18
|
+
function lenientSwitch(raw) {
|
|
19
|
+
return { ok: true, value: raw === true ? true : undefined };
|
|
20
|
+
}
|
|
21
|
+
function parseOrientation(raw) {
|
|
22
|
+
if (raw === '')
|
|
23
|
+
return { ok: true, value: undefined };
|
|
24
|
+
const lower = typeof raw === 'string' ? raw.toLowerCase() : undefined;
|
|
25
|
+
const found = ORIENTATIONS.find((orientation) => orientation === lower);
|
|
26
|
+
if (found)
|
|
27
|
+
return { ok: true, value: found };
|
|
28
|
+
return { ok: false, detail: 'must be an orientation', expected: ORIENTATIONS };
|
|
29
|
+
}
|
|
30
|
+
function parseMargin(raw) {
|
|
31
|
+
if (raw === '')
|
|
32
|
+
return { ok: true, value: undefined };
|
|
33
|
+
// A bare number is points; YAML and JSON hand the rc one over as a number.
|
|
34
|
+
if (typeof raw === 'number' && Number.isFinite(raw) && raw >= 0) {
|
|
35
|
+
return { ok: true, value: raw };
|
|
36
|
+
}
|
|
37
|
+
const text = String(raw);
|
|
38
|
+
if (/^\d+(?:\.\d+)?$/.test(text))
|
|
39
|
+
return { ok: true, value: Number(text) };
|
|
40
|
+
try {
|
|
41
|
+
return { ok: true, value: lengthToPoints(parseLength(text)) };
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
return { ok: false, detail: err instanceof Error ? err.message : String(err) };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Every option the CLI resolves over its flag and rc layers: the shared five, then its own. */
|
|
48
|
+
export const CLI_OPTION_SPECS = Object.freeze({
|
|
49
|
+
...SURFACE_OPTION_SPECS,
|
|
50
|
+
orientation: { rcKey: 'pdfOrientation', parse: parseOrientation },
|
|
51
|
+
margin: { rcKey: 'pdfMargin', parse: parseMargin },
|
|
52
|
+
defaultFormat: { rcKey: 'defaultFormat', parse: lenientString },
|
|
53
|
+
fontSans: { rcKey: 'fontSans', parse: lenientString },
|
|
54
|
+
fontMono: { rcKey: 'fontMono', parse: lenientString },
|
|
55
|
+
headless: { rcKey: 'headlessFonts', parse: lenientSwitch },
|
|
56
|
+
useSystemFonts: { rcKey: 'useSystemFonts', parse: lenientSwitch },
|
|
57
|
+
locale: { rcKey: 'locale', parse: lenientString },
|
|
58
|
+
assetRoot: ASSET_ROOT_SPEC,
|
|
59
|
+
});
|
|
60
|
+
/** The flag each option is passed as, for an error that names its source. */
|
|
61
|
+
const FLAG_NAMES = {
|
|
62
|
+
theme: '--theme',
|
|
63
|
+
width: '--width',
|
|
64
|
+
now: '--now',
|
|
65
|
+
pageSize: '--page-size',
|
|
66
|
+
nonWorking: '--non-working',
|
|
67
|
+
orientation: '--orientation',
|
|
68
|
+
margin: '--margin',
|
|
69
|
+
fontSans: '--font-sans',
|
|
70
|
+
fontMono: '--font-mono',
|
|
71
|
+
headless: '--headless',
|
|
72
|
+
useSystemFonts: '--use-system-fonts',
|
|
73
|
+
assetRoot: '--asset-root',
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Resolve the CLI's options over the flag layer, then the `.nowlinerc` layer.
|
|
77
|
+
* `render` and `--serve` both call this, so they read the same keys the same
|
|
78
|
+
* way. `cwd` is what a relative `--asset-root` resolves against (default: the
|
|
79
|
+
* process's). Nothing throws here: a caller reads `defaultFormat` early and reports bad
|
|
80
|
+
* values at the point it always did, through `assertValid`.
|
|
81
|
+
*/
|
|
82
|
+
export function resolveCliOptions(args, config, context = {}) {
|
|
83
|
+
const { rcPath, cwd, clock } = context;
|
|
84
|
+
const layers = [flagLayer(args), rcLayer(config ?? {}, CLI_OPTION_SPECS)];
|
|
85
|
+
// `--timezone` is validated even when `--now` is explicit, as it always was.
|
|
86
|
+
const zone = readZone(args.timezone);
|
|
87
|
+
const { options, errors: surfaceErrors } = resolveSurfaceOptions(layers, { theme: 'light' }, { zone: zone.zone, clock });
|
|
88
|
+
const { values, errors: cliErrors } = resolveOptions(CLI_OPTION_SPECS, layers);
|
|
89
|
+
const failures = new Map([...surfaceErrors, ...cliErrors].map((error) => [error.key, error]));
|
|
90
|
+
const failure = (key) => {
|
|
91
|
+
const error = failures.get(key);
|
|
92
|
+
return error && new CliError(ExitCode.InputError, formatOptionError(error));
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
surface: options,
|
|
96
|
+
orientation: values.orientation,
|
|
97
|
+
margin: values.margin,
|
|
98
|
+
defaultFormat: values.defaultFormat,
|
|
99
|
+
fontSans: values.fontSans,
|
|
100
|
+
fontMono: values.fontMono,
|
|
101
|
+
headless: values.headless ?? false,
|
|
102
|
+
useSystemFonts: values.useSystemFonts ?? false,
|
|
103
|
+
assetRoot: absoluteAssetRoot(values.assetRoot, args.assetRoot !== undefined, rcPath, cwd),
|
|
104
|
+
rcLocale: values.locale,
|
|
105
|
+
assertValid: () => throwFirst([
|
|
106
|
+
failure('theme'),
|
|
107
|
+
zone.error,
|
|
108
|
+
failure('now'),
|
|
109
|
+
failure('width'),
|
|
110
|
+
failure('nonWorking'),
|
|
111
|
+
failure('assetRoot'),
|
|
112
|
+
]),
|
|
113
|
+
assertPdfSettingsValid: () => throwFirst([failure('pageSize'), failure('orientation'), failure('margin')]),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function throwFirst(candidates) {
|
|
117
|
+
for (const candidate of candidates) {
|
|
118
|
+
if (candidate)
|
|
119
|
+
throw candidate;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function flagLayer(args) {
|
|
123
|
+
return {
|
|
124
|
+
source: (key) => ({ kind: 'flag', name: FLAG_NAMES[key] ?? `--${key}` }),
|
|
125
|
+
values: {
|
|
126
|
+
// An empty `--theme ""` has always meant "not passed", so the rc theme applies.
|
|
127
|
+
theme: args.theme || undefined,
|
|
128
|
+
width: args.width,
|
|
129
|
+
now: args.now,
|
|
130
|
+
pageSize: args.pageSize,
|
|
131
|
+
nonWorking: args.nonWorking,
|
|
132
|
+
orientation: args.orientation,
|
|
133
|
+
margin: args.margin,
|
|
134
|
+
fontSans: args.fontSans,
|
|
135
|
+
fontMono: args.fontMono,
|
|
136
|
+
assetRoot: args.assetRoot,
|
|
137
|
+
// A switch flag is absent or on; absent leaves the rc to decide.
|
|
138
|
+
headless: args.headless || undefined,
|
|
139
|
+
useSystemFonts: args.useSystemFonts || undefined,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function readZone(raw) {
|
|
144
|
+
if (!raw)
|
|
145
|
+
return {};
|
|
146
|
+
try {
|
|
147
|
+
return { zone: normalizeZone(raw) };
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
if (err instanceof TimezoneError) {
|
|
151
|
+
return { error: new CliError(ExitCode.InputError, err.message) };
|
|
152
|
+
}
|
|
153
|
+
throw err;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// ---- Asset root -------------------------------------------------------------
|
|
157
|
+
/**
|
|
158
|
+
* The asset root as an absolute path. A flag resolves against `cwd` (the
|
|
159
|
+
* process's, unless a caller passes its own); an rc value against the
|
|
160
|
+
* directory of the `.nowlinerc` it came from, so a checked-in `assetRoot:
|
|
161
|
+
* assets` means the same directory wherever `nowline` is run from.
|
|
162
|
+
*/
|
|
163
|
+
function absoluteAssetRoot(value, fromFlag, rcPath, cwd) {
|
|
164
|
+
if (value === undefined)
|
|
165
|
+
return undefined;
|
|
166
|
+
if (fromFlag || rcPath === undefined)
|
|
167
|
+
return path.resolve(cwd ?? '.', value);
|
|
168
|
+
return path.resolve(path.dirname(rcPath), value);
|
|
169
|
+
}
|
|
170
|
+
// ---- Error text -------------------------------------------------------------
|
|
171
|
+
/**
|
|
172
|
+
* An {@link OptionError} in the CLI's wording, naming the flag or `.nowlinerc`
|
|
173
|
+
* key the value came from: `nowline: invalid --width "abc". Must be an integer
|
|
174
|
+
* ≥ 320.` The templates are the ones the CLI used before the schema, so
|
|
175
|
+
* scripts that match them keep working.
|
|
176
|
+
*/
|
|
177
|
+
export function formatOptionError(error) {
|
|
178
|
+
const lead = `nowline: invalid ${describeSource(error.source)} "${String(error.raw)}"`;
|
|
179
|
+
if (error.expected)
|
|
180
|
+
return `${lead}. Expected ${formatChoices(error.expected)}.`;
|
|
181
|
+
switch (error.key) {
|
|
182
|
+
// Detail reads "must be YYYY-MM-DD, ...": the CLI says "Expected".
|
|
183
|
+
case 'now':
|
|
184
|
+
return `${lead}. Expected ${error.detail.replace(/^must be /, '')}.`;
|
|
185
|
+
// These two carry the parser's own message after a colon.
|
|
186
|
+
case 'pageSize':
|
|
187
|
+
case 'margin':
|
|
188
|
+
return `${lead}: ${error.detail}`;
|
|
189
|
+
default:
|
|
190
|
+
return `${lead}. ${error.detail.charAt(0).toUpperCase()}${error.detail.slice(1)}.`;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function describeSource(source) {
|
|
194
|
+
switch (source.kind) {
|
|
195
|
+
case 'flag':
|
|
196
|
+
case 'argument':
|
|
197
|
+
case 'setting':
|
|
198
|
+
return source.name;
|
|
199
|
+
case 'rc':
|
|
200
|
+
return `.nowlinerc ${source.key}`;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// `a`, `a or b`, `a, b, or c`.
|
|
204
|
+
export function formatChoices(names) {
|
|
205
|
+
if (names.length <= 2)
|
|
206
|
+
return names.join(' or ');
|
|
207
|
+
return `${names.slice(0, -1).join(', ')}, or ${names[names.length - 1]}`;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src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2
2
|
import type { ParsedArgs } from '../cli/args.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type LoadConfigResult } from '../io/config.js';
|
|
4
4
|
import { type Log } from '../io/log.js';
|
|
5
5
|
export interface RenderHandlerOptions {
|
|
6
6
|
args: ParsedArgs;
|
|
@@ -13,7 +13,7 @@ export interface RenderHandlerOptions {
|
|
|
13
13
|
* step), `--input-format`, and `.json` AST input.
|
|
14
14
|
*/
|
|
15
15
|
export declare function renderHandler(options: RenderHandlerOptions): Promise<void>;
|
|
16
|
-
export declare function loadConfigFor(inputArg: string, cwd: string): Promise<
|
|
16
|
+
export declare function loadConfigFor(inputArg: string, cwd: string): Promise<LoadConfigResult>;
|
|
17
17
|
/** Under `-q`, text-mode diagnostics keep only errors. Shared with serve. */
|
|
18
18
|
export declare function errorsOnlyWhenQuiet<T extends {
|
|
19
19
|
severity: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA0BjD,OAAO,EAAE,KAAK,gBAAgB,EAAc,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC;AAInD,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,UAAU,CAAC;IACjB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiGhF;AA2XD,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAW5F;AAyCD,6EAA6E;AAC7E,wBAAgB,mBAAmB,CAAC,CAAC,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC9D,WAAW,EAAE,CAAC,EAAE,EAChB,GAAG,EAAE,GAAG,GACT,CAAC,EAAE,CAEL;AAID,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAWpE"}
|