@qui-cli/plugin 3.0.0 → 4.0.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/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [4.0.0](https://github.com/battis/qui-cli/compare/plugin/3.0.0...plugin/4.0.0) (2025-11-07)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * group arguments by plugin in usage
11
+ * auto-document default arg values
12
+
13
+ ### revert
14
+
15
+ * group arguments by plugin in usage ([ec3d4bf](https://github.com/battis/qui-cli/commit/ec3d4bf6ef9c59a6da3ede8603554d2dcd2581ad))
16
+
17
+
18
+ ### Features
19
+
20
+ * auto-document default arg values ([e01e157](https://github.com/battis/qui-cli/commit/e01e157f06a3a801628ca79366e3f0060be2322e))
21
+
5
22
  ## [3.0.0](https://github.com/battis/qui-cli/compare/plugin/2.4.2...plugin/3.0.0) (2025-08-02)
6
23
 
7
24
 
package/README.md CHANGED
@@ -158,7 +158,7 @@ export function options() {
158
158
  },
159
159
  opt: {
160
160
  bar: {
161
- description: `Bar value (default: "argle-bargle")`,
161
+ description: `Bar value`,
162
162
  short: 'b',
163
163
  default: 'argle-bargle'
164
164
  }
package/dist/Options.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { ConfigMetaSet, ConfigSet, ConfigType } from 'jackspeak';
2
+ type DocumentationOptions = {
3
+ [longOption: string]: {
4
+ secret?: boolean;
5
+ };
6
+ };
2
7
  type MetaSet<T extends ConfigType> = {
3
- value: ConfigMetaSet<T, false>;
4
- list: ConfigMetaSet<T, true>;
8
+ value: ConfigMetaSet<T, false> & DocumentationOptions;
9
+ list: ConfigMetaSet<T, true> & DocumentationOptions;
5
10
  };
6
11
  type opt = MetaSet<'string'>;
7
12
  type flag = MetaSet<'boolean'>;
@@ -21,6 +26,6 @@ export type Options = {
21
26
  fields?: ConfigSet;
22
27
  man?: Paragraph[];
23
28
  };
24
- export declare function merge<A extends Options = Options, B extends Options = Options>(a: A, b: B): A & B;
29
+ export declare function documentDefaults(options: Options): Options;
25
30
  export type Hook = () => Options | Promise<Options>;
26
31
  export {};
package/dist/Options.js CHANGED
@@ -1,12 +1,46 @@
1
- export function merge(a, b) {
2
- return {
3
- num: { ...a.num, ...b.num },
4
- numList: { ...a.numList, ...b.numList },
5
- opt: { ...a.opt, ...b.opt },
6
- optList: { ...a.optList, ...b.optList },
7
- flag: { ...a.flag, ...b.flag },
8
- flagList: { ...a.flagList, ...b.flagList },
9
- fields: { ...a.fields, ...b.fields },
10
- man: [...(a.man || []), ...(b.man || [])]
11
- };
1
+ import { Colors } from '@qui-cli/colors';
2
+ function stringify(value) {
3
+ switch (typeof value) {
4
+ case 'string':
5
+ return Colors.quotedValue(`"${value}"`);
6
+ case 'object':
7
+ return Colors.regexpValue(value);
8
+ default:
9
+ return Colors.value(value);
10
+ }
11
+ }
12
+ export function documentDefaults(options) {
13
+ let paramType;
14
+ for (paramType in options) {
15
+ if (paramType !== 'man' && paramType !== 'fields') {
16
+ const params = options[paramType];
17
+ if (params) {
18
+ let paramName;
19
+ for (paramName in params) {
20
+ const param = params[paramName];
21
+ let docs = '';
22
+ if (param.default !== undefined && !param.secret) {
23
+ if (!docs.length) {
24
+ docs = 'Default';
25
+ }
26
+ docs = `${docs}: ${Array.isArray(param.default)
27
+ ? param.default.map((v) => stringify(v)).join(', ')
28
+ : stringify(param.default)}`;
29
+ }
30
+ if (paramType === 'flag' && param.default) {
31
+ docs = `${docs}${docs.length ? ', u' : 'U'}se ${Colors.flagArg(`--no-${paramName}`)} to disable`;
32
+ }
33
+ if (docs.length) {
34
+ if (param.description?.length) {
35
+ param.description = `${param.description} (${docs})`;
36
+ }
37
+ else {
38
+ param.description = docs;
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ return options;
12
46
  }
@@ -10,6 +10,5 @@ export type Configuration = {
10
10
  [key: string]: PluginConfiguration;
11
11
  };
12
12
  export declare function configure(config?: Configuration): Promise<void>;
13
- export declare function options(): Promise<Options>;
14
- export declare function init(args: Arguments<Awaited<ReturnType<typeof options>>>): Promise<void>;
13
+ export declare function init(args: Arguments<Options>): Promise<void>;
15
14
  export declare function run(): Promise<AccumulatedResults>;
package/dist/Registrar.js CHANGED
@@ -1,4 +1,4 @@
1
- import { merge } from './Options.js';
1
+ import { documentDefaults } from './Options.js';
2
2
  const plugins = [];
3
3
  export function registered() {
4
4
  return plugins;
@@ -12,7 +12,17 @@ export async function register(plugin) {
12
12
  return;
13
13
  }
14
14
  }
15
- plugins.push(plugin);
15
+ plugins.push({
16
+ ...plugin,
17
+ options: async () => {
18
+ if (plugin.options) {
19
+ return documentDefaults(await plugin.options());
20
+ }
21
+ else {
22
+ return {};
23
+ }
24
+ }
25
+ });
16
26
  }
17
27
  export function reset() {
18
28
  for (const name in plugins) {
@@ -26,15 +36,6 @@ export async function configure(config = {}) {
26
36
  }
27
37
  }
28
38
  }
29
- export async function options() {
30
- let options = {};
31
- for (const plugin of plugins) {
32
- if (plugin.options) {
33
- options = merge(options, await plugin.options());
34
- }
35
- }
36
- return options;
37
- }
38
39
  export async function init(args) {
39
40
  for (const plugin of plugins) {
40
41
  if (plugin.init) {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
- import { merge } from './Options.js';
2
- import { register } from './Registrar.js';
3
1
  export { Base as Configuration } from './Configuration.js';
4
2
  export { Arguments, ExpectedArguments } from './Initialization.js';
5
- export { Options } from './Options.js';
3
+ export { Options, documentDefaults } from './Options.js';
6
4
  export * as Registrar from './Registrar.js';
7
5
  export { AccumulatedResults } from './Run.js';
8
6
  export * from './Utilities.js';
9
- export { merge as mergeOptions, register };
7
+ export { register } from './Registrar.js';
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import { merge } from './Options.js';
2
- import { register } from './Registrar.js';
1
+ export { documentDefaults } from './Options.js';
3
2
  export * as Registrar from './Registrar.js';
4
3
  export * from './Utilities.js';
5
- export { merge as mergeOptions, register };
4
+ export { register } from './Registrar.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qui-cli/plugin",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "@qui-cli plugin structure and registrar",
5
5
  "homepage": "https://github.com/battis/qui-cli/tree/main/packages/plugin#readme",
6
6
  "repository": {
@@ -17,15 +17,16 @@
17
17
  "main": "./dist/index.js",
18
18
  "types": "./dist/index.d.ts",
19
19
  "dependencies": {
20
- "jackspeak": "^4.1.1"
20
+ "jackspeak": "^4.1.1",
21
+ "@qui-cli/colors": "3.1.0"
21
22
  },
22
23
  "devDependencies": {
23
24
  "@tsconfig/node20": "^20.1.6",
24
- "@types/node": "^24.1.0",
25
- "commit-and-tag-version": "^12.5.2",
25
+ "@types/node": "^24.10.0",
26
+ "commit-and-tag-version": "^12.6.0",
26
27
  "del-cli": "^6.0.0",
27
28
  "npm-run-all": "^4.1.5",
28
- "typescript": "^5.9.2"
29
+ "typescript": "^5.9.3"
29
30
  },
30
31
  "target": "node",
31
32
  "scripts": {