@optique/core 0.5.0-dev.63 → 0.5.0-dev.64
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/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/message.cjs +21 -1
- package/dist/message.d.cts +24 -1
- package/dist/message.d.ts +24 -1
- package/dist/message.js +21 -2
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ exports.choice = require_valueparser.choice;
|
|
|
12
12
|
exports.command = require_parser.command;
|
|
13
13
|
exports.concat = require_parser.concat;
|
|
14
14
|
exports.constant = require_parser.constant;
|
|
15
|
+
exports.envVar = require_message.envVar;
|
|
15
16
|
exports.flag = require_parser.flag;
|
|
16
17
|
exports.float = require_valueparser.float;
|
|
17
18
|
exports.formatDocPage = require_doc.formatDocPage;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Message, MessageFormatOptions, MessageTerm, formatMessage, message, metavar, optionName, optionNames, text, value, values } from "./message.cjs";
|
|
1
|
+
import { Message, MessageFormatOptions, MessageTerm, envVar, formatMessage, message, metavar, optionName, optionNames, text, value, values } from "./message.cjs";
|
|
2
2
|
import { OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, formatUsage, formatUsageTerm, normalizeUsage } from "./usage.cjs";
|
|
3
3
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowDefaultOptions, formatDocPage } from "./doc.cjs";
|
|
4
4
|
import { ChoiceOptions, FloatOptions, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, float, integer, isValueParser, locale, string, url, uuid } from "./valueparser.cjs";
|
|
5
5
|
import { ArgumentOptions, CommandOptions, DocState, FlagOptions, InferValue, MultipleOptions, OptionOptions, Parser, ParserContext, ParserResult, Result, WithDefaultError, argument, command, concat, constant, flag, getDocPage, group, longestMatch, map, merge, multiple, object, option, optional, or, parse, tuple, withDefault } from "./parser.cjs";
|
|
6
6
|
import { RunError, RunOptions, run } from "./facade.cjs";
|
|
7
|
-
export { ArgumentOptions, ChoiceOptions, CommandOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, FlagOptions, FloatOptions, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, Message, MessageFormatOptions, MessageTerm, MultipleOptions, OptionName, OptionOptions, Parser, ParserContext, ParserResult, Result, RunError, RunOptions, ShowDefaultOptions, StringOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, argument, choice, command, concat, constant, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, object, option, optionName, optionNames, optional, or, parse, run, string, text, tuple, url, uuid, value, values, withDefault };
|
|
7
|
+
export { ArgumentOptions, ChoiceOptions, CommandOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, FlagOptions, FloatOptions, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, Message, MessageFormatOptions, MessageTerm, MultipleOptions, OptionName, OptionOptions, Parser, ParserContext, ParserResult, Result, RunError, RunOptions, ShowDefaultOptions, StringOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, argument, choice, command, concat, constant, envVar, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, object, option, optionName, optionNames, optional, or, parse, run, string, text, tuple, url, uuid, value, values, withDefault };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Message, MessageFormatOptions, MessageTerm, formatMessage, message, metavar, optionName, optionNames, text, value, values } from "./message.js";
|
|
1
|
+
import { Message, MessageFormatOptions, MessageTerm, envVar, formatMessage, message, metavar, optionName, optionNames, text, value, values } from "./message.js";
|
|
2
2
|
import { OptionName, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, formatUsage, formatUsageTerm, normalizeUsage } from "./usage.js";
|
|
3
3
|
import { DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, ShowDefaultOptions, formatDocPage } from "./doc.js";
|
|
4
4
|
import { ChoiceOptions, FloatOptions, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, StringOptions, UrlOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, choice, float, integer, isValueParser, locale, string, url, uuid } from "./valueparser.js";
|
|
5
5
|
import { ArgumentOptions, CommandOptions, DocState, FlagOptions, InferValue, MultipleOptions, OptionOptions, Parser, ParserContext, ParserResult, Result, WithDefaultError, argument, command, concat, constant, flag, getDocPage, group, longestMatch, map, merge, multiple, object, option, optional, or, parse, tuple, withDefault } from "./parser.js";
|
|
6
6
|
import { RunError, RunOptions, run } from "./facade.js";
|
|
7
|
-
export { ArgumentOptions, ChoiceOptions, CommandOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, FlagOptions, FloatOptions, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, Message, MessageFormatOptions, MessageTerm, MultipleOptions, OptionName, OptionOptions, Parser, ParserContext, ParserResult, Result, RunError, RunOptions, ShowDefaultOptions, StringOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, argument, choice, command, concat, constant, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, object, option, optionName, optionNames, optional, or, parse, run, string, text, tuple, url, uuid, value, values, withDefault };
|
|
7
|
+
export { ArgumentOptions, ChoiceOptions, CommandOptions, DocEntry, DocFragment, DocFragments, DocPage, DocPageFormatOptions, DocSection, DocState, FlagOptions, FloatOptions, InferValue, IntegerOptionsBigInt, IntegerOptionsNumber, LocaleOptions, Message, MessageFormatOptions, MessageTerm, MultipleOptions, OptionName, OptionOptions, Parser, ParserContext, ParserResult, Result, RunError, RunOptions, ShowDefaultOptions, StringOptions, UrlOptions, Usage, UsageFormatOptions, UsageTerm, UsageTermFormatOptions, Uuid, UuidOptions, ValueParser, ValueParserResult, WithDefaultError, argument, choice, command, concat, constant, envVar, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, object, option, optionName, optionNames, optional, or, parse, run, string, text, tuple, url, uuid, value, values, withDefault };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { formatMessage, message, metavar, optionName, optionNames, text, value, values } from "./message.js";
|
|
1
|
+
import { envVar, formatMessage, message, metavar, optionName, optionNames, text, value, values } from "./message.js";
|
|
2
2
|
import { formatUsage, formatUsageTerm, normalizeUsage } from "./usage.js";
|
|
3
3
|
import { formatDocPage } from "./doc.js";
|
|
4
4
|
import { choice, float, integer, isValueParser, locale, string, url, uuid } from "./valueparser.js";
|
|
5
5
|
import { WithDefaultError, argument, command, concat, constant, flag, getDocPage, group, longestMatch, map, merge, multiple, object, option, optional, or, parse, tuple, withDefault } from "./parser.js";
|
|
6
6
|
import { RunError, run } from "./facade.js";
|
|
7
7
|
|
|
8
|
-
export { RunError, WithDefaultError, argument, choice, command, concat, constant, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, object, option, optionName, optionNames, optional, or, parse, run, string, text, tuple, url, uuid, value, values, withDefault };
|
|
8
|
+
export { RunError, WithDefaultError, argument, choice, command, concat, constant, envVar, flag, float, formatDocPage, formatMessage, formatUsage, formatUsageTerm, getDocPage, group, integer, isValueParser, locale, longestMatch, map, merge, message, metavar, multiple, normalizeUsage, object, option, optionName, optionNames, optional, or, parse, run, string, text, tuple, url, uuid, value, values, withDefault };
|
package/dist/message.cjs
CHANGED
|
@@ -113,6 +113,19 @@ function values(values$1) {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
|
+
* Creates a {@link MessageTerm} for an environment variable.
|
|
117
|
+
* @param envVar The environment variable name, which is a string that represents
|
|
118
|
+
* an environment variable. For example, `"PATH"` or `"API_URL"`.
|
|
119
|
+
* @returns A {@link MessageTerm} representing the environment variable.
|
|
120
|
+
* @since 0.5.0
|
|
121
|
+
*/
|
|
122
|
+
function envVar(envVar$1) {
|
|
123
|
+
return {
|
|
124
|
+
type: "envVar",
|
|
125
|
+
envVar: envVar$1
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
116
129
|
* Formats a {@link Message} into a human-readable string for
|
|
117
130
|
* the terminal.
|
|
118
131
|
* @param msg The message to format, which is an array of
|
|
@@ -176,7 +189,13 @@ function formatMessage(msg, options = {}) {
|
|
|
176
189
|
width: value$1.length
|
|
177
190
|
};
|
|
178
191
|
}
|
|
179
|
-
else
|
|
192
|
+
else if (term.type === "envVar") {
|
|
193
|
+
const envVar$1 = useQuotes ? `\`${term.envVar}\`` : term.envVar;
|
|
194
|
+
yield {
|
|
195
|
+
text: useColors ? `\x1b[1;4m${envVar$1}\x1b[0m` : envVar$1,
|
|
196
|
+
width: envVar$1.length
|
|
197
|
+
};
|
|
198
|
+
} else throw new TypeError(`Invalid MessageTerm type: ${term["type"]}.`);
|
|
180
199
|
}
|
|
181
200
|
let output = "";
|
|
182
201
|
let totalWidth = 0;
|
|
@@ -192,6 +211,7 @@ function formatMessage(msg, options = {}) {
|
|
|
192
211
|
}
|
|
193
212
|
|
|
194
213
|
//#endregion
|
|
214
|
+
exports.envVar = envVar;
|
|
195
215
|
exports.formatMessage = formatMessage;
|
|
196
216
|
exports.message = message;
|
|
197
217
|
exports.metavar = metavar;
|
package/dist/message.d.cts
CHANGED
|
@@ -89,6 +89,21 @@ type MessageTerm =
|
|
|
89
89
|
* representations of consecutive values. For example, `["42", "hello"]`.
|
|
90
90
|
*/
|
|
91
91
|
readonly values: readonly string[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* An environment variable term in the message, which represents
|
|
95
|
+
* an environment variable name.
|
|
96
|
+
* @since 0.5.0
|
|
97
|
+
*/ | {
|
|
98
|
+
/**
|
|
99
|
+
* The type of the term, which is `"envVar"` for an environment variable.
|
|
100
|
+
*/
|
|
101
|
+
readonly type: "envVar";
|
|
102
|
+
/**
|
|
103
|
+
* The environment variable name, which is a string that represents
|
|
104
|
+
* an environment variable. For example, `"PATH"` or `"API_URL"`.
|
|
105
|
+
*/
|
|
106
|
+
readonly envVar: string;
|
|
92
107
|
};
|
|
93
108
|
/**
|
|
94
109
|
* Type representing a message that can include styled/colored values.
|
|
@@ -160,6 +175,14 @@ declare function value(value: string): MessageTerm;
|
|
|
160
175
|
* @returns A {@link MessageTerm} representing the list of values.
|
|
161
176
|
*/
|
|
162
177
|
declare function values(values: readonly string[]): MessageTerm;
|
|
178
|
+
/**
|
|
179
|
+
* Creates a {@link MessageTerm} for an environment variable.
|
|
180
|
+
* @param envVar The environment variable name, which is a string that represents
|
|
181
|
+
* an environment variable. For example, `"PATH"` or `"API_URL"`.
|
|
182
|
+
* @returns A {@link MessageTerm} representing the environment variable.
|
|
183
|
+
* @since 0.5.0
|
|
184
|
+
*/
|
|
185
|
+
declare function envVar(envVar: string): MessageTerm;
|
|
163
186
|
/**
|
|
164
187
|
* Options for the {@link formatMessage} function.
|
|
165
188
|
*/
|
|
@@ -196,4 +219,4 @@ interface MessageFormatOptions {
|
|
|
196
219
|
*/
|
|
197
220
|
declare function formatMessage(msg: Message, options?: MessageFormatOptions): string;
|
|
198
221
|
//#endregion
|
|
199
|
-
export { Message, MessageFormatOptions, MessageTerm, formatMessage, message, metavar, optionName, optionNames, text, value, values };
|
|
222
|
+
export { Message, MessageFormatOptions, MessageTerm, envVar, formatMessage, message, metavar, optionName, optionNames, text, value, values };
|
package/dist/message.d.ts
CHANGED
|
@@ -89,6 +89,21 @@ type MessageTerm =
|
|
|
89
89
|
* representations of consecutive values. For example, `["42", "hello"]`.
|
|
90
90
|
*/
|
|
91
91
|
readonly values: readonly string[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* An environment variable term in the message, which represents
|
|
95
|
+
* an environment variable name.
|
|
96
|
+
* @since 0.5.0
|
|
97
|
+
*/ | {
|
|
98
|
+
/**
|
|
99
|
+
* The type of the term, which is `"envVar"` for an environment variable.
|
|
100
|
+
*/
|
|
101
|
+
readonly type: "envVar";
|
|
102
|
+
/**
|
|
103
|
+
* The environment variable name, which is a string that represents
|
|
104
|
+
* an environment variable. For example, `"PATH"` or `"API_URL"`.
|
|
105
|
+
*/
|
|
106
|
+
readonly envVar: string;
|
|
92
107
|
};
|
|
93
108
|
/**
|
|
94
109
|
* Type representing a message that can include styled/colored values.
|
|
@@ -160,6 +175,14 @@ declare function value(value: string): MessageTerm;
|
|
|
160
175
|
* @returns A {@link MessageTerm} representing the list of values.
|
|
161
176
|
*/
|
|
162
177
|
declare function values(values: readonly string[]): MessageTerm;
|
|
178
|
+
/**
|
|
179
|
+
* Creates a {@link MessageTerm} for an environment variable.
|
|
180
|
+
* @param envVar The environment variable name, which is a string that represents
|
|
181
|
+
* an environment variable. For example, `"PATH"` or `"API_URL"`.
|
|
182
|
+
* @returns A {@link MessageTerm} representing the environment variable.
|
|
183
|
+
* @since 0.5.0
|
|
184
|
+
*/
|
|
185
|
+
declare function envVar(envVar: string): MessageTerm;
|
|
163
186
|
/**
|
|
164
187
|
* Options for the {@link formatMessage} function.
|
|
165
188
|
*/
|
|
@@ -196,4 +219,4 @@ interface MessageFormatOptions {
|
|
|
196
219
|
*/
|
|
197
220
|
declare function formatMessage(msg: Message, options?: MessageFormatOptions): string;
|
|
198
221
|
//#endregion
|
|
199
|
-
export { Message, MessageFormatOptions, MessageTerm, formatMessage, message, metavar, optionName, optionNames, text, value, values };
|
|
222
|
+
export { Message, MessageFormatOptions, MessageTerm, envVar, formatMessage, message, metavar, optionName, optionNames, text, value, values };
|
package/dist/message.js
CHANGED
|
@@ -112,6 +112,19 @@ function values(values$1) {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
|
+
* Creates a {@link MessageTerm} for an environment variable.
|
|
116
|
+
* @param envVar The environment variable name, which is a string that represents
|
|
117
|
+
* an environment variable. For example, `"PATH"` or `"API_URL"`.
|
|
118
|
+
* @returns A {@link MessageTerm} representing the environment variable.
|
|
119
|
+
* @since 0.5.0
|
|
120
|
+
*/
|
|
121
|
+
function envVar(envVar$1) {
|
|
122
|
+
return {
|
|
123
|
+
type: "envVar",
|
|
124
|
+
envVar: envVar$1
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
115
128
|
* Formats a {@link Message} into a human-readable string for
|
|
116
129
|
* the terminal.
|
|
117
130
|
* @param msg The message to format, which is an array of
|
|
@@ -175,7 +188,13 @@ function formatMessage(msg, options = {}) {
|
|
|
175
188
|
width: value$1.length
|
|
176
189
|
};
|
|
177
190
|
}
|
|
178
|
-
else
|
|
191
|
+
else if (term.type === "envVar") {
|
|
192
|
+
const envVar$1 = useQuotes ? `\`${term.envVar}\`` : term.envVar;
|
|
193
|
+
yield {
|
|
194
|
+
text: useColors ? `\x1b[1;4m${envVar$1}\x1b[0m` : envVar$1,
|
|
195
|
+
width: envVar$1.length
|
|
196
|
+
};
|
|
197
|
+
} else throw new TypeError(`Invalid MessageTerm type: ${term["type"]}.`);
|
|
179
198
|
}
|
|
180
199
|
let output = "";
|
|
181
200
|
let totalWidth = 0;
|
|
@@ -191,4 +210,4 @@ function formatMessage(msg, options = {}) {
|
|
|
191
210
|
}
|
|
192
211
|
|
|
193
212
|
//#endregion
|
|
194
|
-
export { formatMessage, message, metavar, optionName, optionNames, text, value, values };
|
|
213
|
+
export { envVar, formatMessage, message, metavar, optionName, optionNames, text, value, values };
|
package/dist/parser.cjs
CHANGED
|
@@ -532,7 +532,7 @@ function optional(parser) {
|
|
|
532
532
|
* withDefault(option("--url", url()), () => {
|
|
533
533
|
* if (!process.env.INSTANCE_URL) {
|
|
534
534
|
* throw new WithDefaultError(
|
|
535
|
-
* message`Environment variable ${
|
|
535
|
+
* message`Environment variable ${envVar("INSTANCE_URL")} is not set.`
|
|
536
536
|
* );
|
|
537
537
|
* }
|
|
538
538
|
* return new URL(process.env.INSTANCE_URL);
|
package/dist/parser.d.cts
CHANGED
|
@@ -286,7 +286,7 @@ declare function optional<TValue, TState>(parser: Parser<TValue, TState>): Parse
|
|
|
286
286
|
* withDefault(option("--url", url()), () => {
|
|
287
287
|
* if (!process.env.INSTANCE_URL) {
|
|
288
288
|
* throw new WithDefaultError(
|
|
289
|
-
* message`Environment variable ${
|
|
289
|
+
* message`Environment variable ${envVar("INSTANCE_URL")} is not set.`
|
|
290
290
|
* );
|
|
291
291
|
* }
|
|
292
292
|
* return new URL(process.env.INSTANCE_URL);
|
package/dist/parser.d.ts
CHANGED
|
@@ -286,7 +286,7 @@ declare function optional<TValue, TState>(parser: Parser<TValue, TState>): Parse
|
|
|
286
286
|
* withDefault(option("--url", url()), () => {
|
|
287
287
|
* if (!process.env.INSTANCE_URL) {
|
|
288
288
|
* throw new WithDefaultError(
|
|
289
|
-
* message`Environment variable ${
|
|
289
|
+
* message`Environment variable ${envVar("INSTANCE_URL")} is not set.`
|
|
290
290
|
* );
|
|
291
291
|
* }
|
|
292
292
|
* return new URL(process.env.INSTANCE_URL);
|
package/dist/parser.js
CHANGED
|
@@ -532,7 +532,7 @@ function optional(parser) {
|
|
|
532
532
|
* withDefault(option("--url", url()), () => {
|
|
533
533
|
* if (!process.env.INSTANCE_URL) {
|
|
534
534
|
* throw new WithDefaultError(
|
|
535
|
-
* message`Environment variable ${
|
|
535
|
+
* message`Environment variable ${envVar("INSTANCE_URL")} is not set.`
|
|
536
536
|
* );
|
|
537
537
|
* }
|
|
538
538
|
* return new URL(process.env.INSTANCE_URL);
|