@gunshi/bone 1.0.0-beta.1 → 1.0.0-beta.2

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.
Files changed (2) hide show
  1. package/lib/index.js +41 -31
  2. package/package.json +5 -5
package/lib/index.js CHANGED
@@ -1254,37 +1254,6 @@ function create(obj = null) {
1254
1254
  return Object.create(obj);
1255
1255
  }
1256
1256
  /**
1257
- * Resolve the arguments of a command, the way gunshi parses and renders them.
1258
- *
1259
- * The global options belong to no command definition, so they are merged into the arguments of the
1260
- * command that runs. An argument of the command shadows the global option of the same name, and it
1261
- * shadows the same way by short name: a global option gives up its short name to an argument of the
1262
- * command that claims the same letter, and keeps its long name.
1263
- *
1264
- * @param globalOptions - The global options that plugins registered with `addGlobalOption`
1265
- * @param args - The arguments that the command declares
1266
- * @returns The merged arguments
1267
- */
1268
- function resolveCommandArgs(globalOptions, args) {
1269
- return Object.assign(create(), resolveGlobalOptions(globalOptions, args), args);
1270
- }
1271
- function resolveGlobalOptions(globalOptions, args) {
1272
- if (!globalOptions) return;
1273
- const shortNames = /* @__PURE__ */ new Set();
1274
- for (const schema of Object.values(args || {})) if (schema.type !== "positional" && schema.short) shortNames.add(schema.short);
1275
- const resolved = create();
1276
- for (const [name, schema] of globalOptions)
1277
- /**
1278
- * NOTE(kazupon): a copy, because the schema is the one that the plugin registered, which every
1279
- * command of the CLI shares. Only this command gives up the short name.
1280
- */
1281
- resolved[name] = schema.short && shortNames.has(schema.short) ? {
1282
- ...schema,
1283
- short: void 0
1284
- } : schema;
1285
- return resolved;
1286
- }
1287
- /**
1288
1257
  * Log a message to the console.
1289
1258
  *
1290
1259
  * @param args - Arguments to log
@@ -1796,6 +1765,47 @@ function resolveDependencies(plugins) {
1796
1765
  return sorted;
1797
1766
  }
1798
1767
  //#endregion
1768
+ //#region ../gunshi/src/cli/args.ts
1769
+ /**
1770
+ * @author kazuya kawaguchi (a.k.a. kazupon)
1771
+ * @license MIT
1772
+ */
1773
+ /**
1774
+ * Resolve the arguments of a command, the way gunshi parses and renders them.
1775
+ *
1776
+ * The global options belong to no command definition, so they are merged into the arguments of the
1777
+ * command that runs. An argument of the command shadows the global option of the same name, and it
1778
+ * shadows the same way by short name: a global option gives up its short name to an argument of the
1779
+ * command that claims the same letter, and keeps its long name.
1780
+ *
1781
+ * NOTE(kazupon): this is not exported from the entry points. `@gunshi/plugin-completion` completes
1782
+ * the arguments the same way with the copy in `@gunshi/shared`, and the tests of that copy pin it
1783
+ * to the results of this one, so a change here has to be made there too.
1784
+ *
1785
+ * @param globalOptions - The global options that plugins registered with `addGlobalOption`
1786
+ * @param args - The arguments that the command declares
1787
+ * @returns The merged arguments
1788
+ */
1789
+ function resolveCommandArgs(globalOptions, args) {
1790
+ return Object.assign(create(), resolveGlobalOptions(globalOptions, args), args);
1791
+ }
1792
+ function resolveGlobalOptions(globalOptions, args) {
1793
+ if (!globalOptions) return;
1794
+ const shortNames = /* @__PURE__ */ new Set();
1795
+ for (const schema of Object.values(args || {})) if (schema.type !== "positional" && schema.short) shortNames.add(schema.short);
1796
+ const resolved = create();
1797
+ for (const [name, schema] of globalOptions)
1798
+ /**
1799
+ * NOTE(kazupon): a copy, because the schema is the one that the plugin registered, which every
1800
+ * command of the CLI shares. Only this command gives up the short name.
1801
+ */
1802
+ resolved[name] = schema.short && shortNames.has(schema.short) ? {
1803
+ ...schema,
1804
+ short: void 0
1805
+ } : schema;
1806
+ return resolved;
1807
+ }
1808
+ //#endregion
1799
1809
  //#region ../gunshi/src/cli/core.ts
1800
1810
  /**
1801
1811
  * @author kazuya kawaguchi (a.k.a. kazupon)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/bone",
3
3
  "description": "gunshi minimum",
4
- "version": "1.0.0-beta.1",
4
+ "version": "1.0.0-beta.2",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -51,11 +51,11 @@
51
51
  }
52
52
  },
53
53
  "devDependencies": {
54
- "@gunshi/definition": "1.0.0-beta.1",
55
- "@gunshi/plugin-global": "1.0.0-beta.1",
56
- "@gunshi/plugin-renderer": "1.0.0-beta.1",
54
+ "@gunshi/definition": "1.0.0-beta.2",
55
+ "@gunshi/plugin-global": "1.0.0-beta.2",
56
+ "@gunshi/plugin-renderer": "1.0.0-beta.2",
57
57
  "deno": "^2.7.14",
58
- "gunshi": "1.0.0-beta.1",
58
+ "gunshi": "1.0.0-beta.2",
59
59
  "jsr": "^0.14.3",
60
60
  "jsr-exports-lint": "^0.4.2",
61
61
  "publint": "^0.3.20",