@clerc/parser 1.0.0-beta.20 → 1.0.0-beta.22

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.d.ts CHANGED
@@ -46,8 +46,8 @@ interface TypeFunction<T = unknown> {
46
46
  * @returns true to stop parsing, false to continue
47
47
  */
48
48
  type IgnoreFunction = (type: typeof KNOWN_FLAG | typeof UNKNOWN_FLAG | typeof PARAMETER, arg: string) => boolean;
49
- type FlagType<T = unknown> = TypeFunction<T> | readonly [TypeFunction<T>];
50
- interface BaseFlagOptions<T extends FlagType = FlagType> {
49
+ type TypeValue<T = unknown> = TypeFunction<T> | readonly [TypeFunction<T>];
50
+ interface BaseFlagOptions<T extends TypeValue = TypeValue> {
51
51
  /**
52
52
  * The type constructor or a function to convert the string value.
53
53
  * To support multiple occurrences of a flag (e.g., --file a --file b), wrap the type in an array: [String], [Number].
@@ -73,7 +73,7 @@ type FlagOptions = (BaseFlagOptions<BooleanConstructor> & {
73
73
  }) | (BaseFlagOptions & {
74
74
  negatable?: never;
75
75
  });
76
- type FlagDefinitionValue = FlagOptions | FlagType;
76
+ type FlagDefinitionValue = FlagOptions | TypeValue;
77
77
  type FlagsDefinition = Record<string, FlagDefinitionValue>;
78
78
  /**
79
79
  * Configuration options for the parser.
@@ -132,10 +132,10 @@ type _InferFlags<T extends FlagsDefinition> = { [K in keyof T]: IsTypeAny<T[K]>
132
132
  type: readonly [BooleanConstructor];
133
133
  } ? number | InferFlagDefault<T[K], never> : T[K] extends ObjectConstructor | {
134
134
  type: ObjectConstructor;
135
- } ? ObjectInputType | InferFlagDefault<T[K], never> : T[K] extends readonly [FlagType<infer U>] | {
136
- type: readonly [FlagType<infer U>];
137
- } ? U[] | InferFlagDefault<T[K], never> : T[K] extends FlagType<infer U> | {
138
- type: FlagType<infer U>;
135
+ } ? ObjectInputType | InferFlagDefault<T[K], never> : T[K] extends readonly [TypeValue<infer U>] | {
136
+ type: readonly [TypeValue<infer U>];
137
+ } ? U[] | InferFlagDefault<T[K], never> : T[K] extends TypeValue<infer U> | {
138
+ type: TypeValue<infer U>;
139
139
  } ? U | InferFlagDefault<T[K], [U] extends [boolean] ? never : T[K] extends {
140
140
  required: true;
141
141
  } ? never : undefined> : never };
@@ -190,4 +190,4 @@ declare function createParser<T extends FlagsDefinition>(options?: ParserOptions
190
190
  };
191
191
  declare const parse: <T extends FlagsDefinition>(args: string[], options?: ParserOptions<T>) => ParsedResult<InferFlags<T>>;
192
192
  //#endregion
193
- export { BaseFlagOptions, DOUBLE_DASH, Enum, FlagDefaultValue, FlagDefaultValueFunction, FlagDefinitionValue, FlagOptions, FlagType, FlagsDefinition, IgnoreFunction, InferFlags, InvalidSchemaError, KNOWN_FLAG, MissingRequiredFlagError, ObjectInputType, PARAMETER, ParsedResult, ParserOptions, Range, RawInputType, Regex, TypeFunction, UNKNOWN_FLAG, createParser, parse };
193
+ export { BaseFlagOptions, DOUBLE_DASH, Enum, FlagDefaultValue, FlagDefaultValueFunction, FlagDefinitionValue, FlagOptions, FlagsDefinition, IgnoreFunction, InferFlags, InvalidSchemaError, KNOWN_FLAG, MissingRequiredFlagError, ObjectInputType, PARAMETER, ParsedResult, ParserOptions, Range, RawInputType, Regex, TypeFunction, TypeValue, UNKNOWN_FLAG, createParser, parse };
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ function Range(min, max) {
50
50
  if (Number.isNaN(num) || num < min || num > max) throw new Error(`Invalid value: ${value}. Must be a number between ${min} and ${max}`);
51
51
  return num;
52
52
  });
53
- fn.display = `${min}-${max}`;
53
+ fn.display = `${min} - ${max}`;
54
54
  return fn;
55
55
  }
56
56
  /**
@@ -66,7 +66,7 @@ function Regex(pattern, description) {
66
66
  if (!pattern.test(value)) throw new Error(`Invalid value: ${value}. Must match pattern: ${pattern}`);
67
67
  return value;
68
68
  });
69
- fn.display = description ?? pattern.toString();
69
+ fn.display = description ?? `Regex: ${pattern.toString()}`;
70
70
  return fn;
71
71
  }
72
72
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/parser",
3
- "version": "1.0.0-beta.20",
3
+ "version": "1.0.0-beta.22",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "type": "module",
6
6
  "description": "Clerc parser",
@@ -56,6 +56,6 @@
56
56
  "nopt": "^9.0.0",
57
57
  "type-flag": "^4.0.3",
58
58
  "yargs-parser": "^22.0.0",
59
- "@clerc/utils": "1.0.0-beta.20"
59
+ "@clerc/utils": "1.0.0-beta.22"
60
60
  }
61
61
  }