gunshi 0.23.0 → 0.23.1

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.
@@ -1,6 +1,6 @@
1
- import { COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, isLazyCommand, resolveLazyCommand } from "./utils-GlOAgmx0.js";
2
- import { createCommandContext } from "./context-B_pkfbdk.js";
3
- import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-8HgcYJqp.js";
1
+ import { ANONYMOUS_COMMAND_NAME, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, isLazyCommand, resolveLazyCommand } from "./utils-D41C8Abf.js";
2
+ import { createCommandContext } from "./context-COFfMm-R.js";
3
+ import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-kzo45gaB.js";
4
4
  import { parseArgs, resolveArgs } from "args-tokens";
5
5
 
6
6
  //#region src/cli.ts
@@ -134,7 +134,7 @@ async function resolveCommand(sub, entry, options) {
134
134
  };
135
135
  }
136
136
  function resolveEntryName(entry) {
137
- return entry.name || "(anonymous)";
137
+ return entry.name || ANONYMOUS_COMMAND_NAME;
138
138
  }
139
139
  async function executeCommand(cmd, ctx, name) {
140
140
  const resolved = isLazyCommand(cmd) ? await resolveLazyCommand(cmd, name, true) : cmd;
@@ -1,4 +1,4 @@
1
- import { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, log, mapResourceWithBuiltinKey, resolveArgKey, resolveExamples, resolveLazyCommand } from "./utils-GlOAgmx0.js";
1
+ import { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveExamples, resolveLazyCommand } from "./utils-D41C8Abf.js";
2
2
 
3
3
  //#region src/locales/en-US.json
4
4
  var COMMAND = "COMMAND";
@@ -125,7 +125,7 @@ async function createCommandContext({ args, values, positionals, rest, argv, tok
125
125
  * create the context
126
126
  */
127
127
  const ctx = deepFreeze(Object.assign(create(), {
128
- name: command.name,
128
+ name: getCommandName(command),
129
129
  description: command.description,
130
130
  omitted,
131
131
  callMode,
@@ -166,6 +166,11 @@ async function createCommandContext({ args, values, positionals, rest, argv, tok
166
166
  }
167
167
  return ctx;
168
168
  }
169
+ function getCommandName(cmd) {
170
+ if (isLazyCommand(cmd)) return cmd.commandName || cmd.name || ANONYMOUS_COMMAND_NAME;
171
+ else if (typeof cmd === "object") return cmd.name || ANONYMOUS_COMMAND_NAME;
172
+ else return ANONYMOUS_COMMAND_NAME;
173
+ }
169
174
  function resolveLocale(locale) {
170
175
  return locale instanceof Intl.Locale ? locale : typeof locale === "string" ? new Intl.Locale(locale) : new Intl.Locale(DEFAULT_LOCALE);
171
176
  }
package/lib/context.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CliOptions, Command, CommandCallMode, CommandContext } from "./types-ZXqvU8Ti.js";
1
+ import { CliOptions, Command, CommandCallMode, CommandContext, LazyCommand } from "./types-BDWiiycu.js";
2
2
  import { ArgToken, ArgValues, Args } from "args-tokens";
3
3
 
4
4
  //#region src/context.d.ts
@@ -43,9 +43,9 @@ interface CommandContextParams<A extends Args, V> {
43
43
  */
44
44
  callMode: CommandCallMode;
45
45
  /**
46
- * A target {@link Command | command}
46
+ * A target command
47
47
  */
48
- command: Command<A>;
48
+ command: Command<A> | LazyCommand<A>;
49
49
  /**
50
50
  * A command options, which is spicialized from `cli` function
51
51
  */
package/lib/context.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./utils-GlOAgmx0.js";
2
- import { createCommandContext } from "./context-B_pkfbdk.js";
1
+ import "./utils-D41C8Abf.js";
2
+ import { createCommandContext } from "./context-COFfMm-R.js";
3
3
 
4
4
  export { createCommandContext };
@@ -1,4 +1,4 @@
1
- import { Command, CommandLoader, LazyCommand } from "./types-ZXqvU8Ti.js";
1
+ import { Command, CommandLoader, LazyCommand } from "./types-BDWiiycu.js";
2
2
  import { ArgSchema, ArgValues as ArgValues$1, Args, Args as Args$1 } from "args-tokens";
3
3
 
4
4
  //#region src/definition.d.ts
@@ -1,3 +1,3 @@
1
- import "./types-ZXqvU8Ti.js";
2
- import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-BFYUOPMR.js";
1
+ import "./types-BDWiiycu.js";
2
+ import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-zTfMFgKw.js";
3
3
  export { ArgSchema, ArgValues, Args, define, lazy };
@@ -1,4 +1,4 @@
1
- import { CliOptions, Command, LazyCommand } from "./types-ZXqvU8Ti.js";
1
+ import { CliOptions, Command, LazyCommand } from "./types-BDWiiycu.js";
2
2
  import { Args } from "args-tokens";
3
3
 
4
4
  //#region src/generator.d.ts
package/lib/generator.js CHANGED
@@ -1,7 +1,7 @@
1
- import { create } from "./utils-GlOAgmx0.js";
2
- import "./context-B_pkfbdk.js";
3
- import "./renderer-8HgcYJqp.js";
4
- import { cli } from "./cli-DBIMF97F.js";
1
+ import { create } from "./utils-D41C8Abf.js";
2
+ import "./context-COFfMm-R.js";
3
+ import "./renderer-kzo45gaB.js";
4
+ import { cli } from "./cli-BVD3QITm.js";
5
5
 
6
6
  //#region src/generator.ts
7
7
  /**
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-ZXqvU8Ti.js";
2
- import { define$1 as define, lazy$1 as lazy } from "./definition-BFYUOPMR.js";
1
+ import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-BDWiiycu.js";
2
+ import { define$1 as define, lazy$1 as lazy } from "./definition-zTfMFgKw.js";
3
3
  import { ArgSchema, ArgValues, Args, Args as Args$1, parseArgs, resolveArgs } from "args-tokens";
4
4
 
5
5
  //#region src/cli.d.ts
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-GlOAgmx0.js";
2
- import { DefaultTranslation } from "./context-B_pkfbdk.js";
1
+ import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-D41C8Abf.js";
2
+ import { DefaultTranslation } from "./context-COFfMm-R.js";
3
3
  import { define, lazy } from "./definition-DyVBFqB7.js";
4
- import "./renderer-8HgcYJqp.js";
5
- import { cli } from "./cli-DBIMF97F.js";
4
+ import "./renderer-kzo45gaB.js";
5
+ import { cli } from "./cli-BVD3QITm.js";
6
6
  import { parseArgs, resolveArgs } from "args-tokens";
7
7
 
8
8
  export { DEFAULT_LOCALE, DefaultTranslation, cli, define, lazy, parseArgs, resolveArgs };
@@ -1,4 +1,4 @@
1
- import { COMMON_ARGS, create, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-GlOAgmx0.js";
1
+ import { COMMON_ARGS, create, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-D41C8Abf.js";
2
2
 
3
3
  //#region src/renderer/header.ts
4
4
  /**
package/lib/renderer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CommandContext } from "./types-ZXqvU8Ti.js";
1
+ import { CommandContext } from "./types-BDWiiycu.js";
2
2
  import { Args } from "args-tokens";
3
3
 
4
4
  //#region src/renderer/header.d.ts
package/lib/renderer.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./utils-GlOAgmx0.js";
2
- import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-8HgcYJqp.js";
1
+ import "./utils-D41C8Abf.js";
2
+ import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-kzo45gaB.js";
3
3
 
4
4
  export { renderHeader, renderUsage, renderValidationErrors };
@@ -2,7 +2,7 @@ import { ArgToken, ArgValues, Args } from "args-tokens";
2
2
 
3
3
  //#region rolldown:runtime
4
4
  declare namespace constants_d_exports {
5
- export { ARG_PREFIX, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE, NOOP };
5
+ export { ANONYMOUS_COMMAND_NAME, ARG_PREFIX, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE, NOOP };
6
6
  }
7
7
  /**
8
8
  * The default locale string, which format is BCP 47 language tag.
@@ -11,6 +11,7 @@ declare const DEFAULT_LOCALE = "en-US";
11
11
  declare const BUILT_IN_PREFIX = "_";
12
12
  declare const ARG_PREFIX = "arg";
13
13
  declare const BUILT_IN_KEY_SEPARATOR = ":";
14
+ declare const ANONYMOUS_COMMAND_NAME = "(anonymous)";
14
15
  declare const NOOP: () => void;
15
16
  type CommonArgType = {
16
17
  readonly help: {
@@ -6,6 +6,7 @@ const DEFAULT_LOCALE = "en-US";
6
6
  const BUILT_IN_PREFIX = "_";
7
7
  const ARG_PREFIX = "arg";
8
8
  const BUILT_IN_KEY_SEPARATOR = ":";
9
+ const ANONYMOUS_COMMAND_NAME = "(anonymous)";
9
10
  const NOOP = () => {};
10
11
  const COMMON_ARGS = {
11
12
  help: {
@@ -99,4 +100,4 @@ function deepFreeze(obj) {
99
100
  }
100
101
 
101
102
  //#endregion
102
- export { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE as DEFAULT_LOCALE$1, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveLazyCommand };
103
+ export { ANONYMOUS_COMMAND_NAME, BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE as DEFAULT_LOCALE$1, NOOP, create, deepFreeze, isLazyCommand, log, mapResourceWithBuiltinKey, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveLazyCommand };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gunshi",
3
3
  "description": "Modern javascript command-line library",
4
- "version": "0.23.0",
4
+ "version": "0.23.1",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -103,7 +103,7 @@
103
103
  "eslint-plugin-vue-composable": "^1.0.0",
104
104
  "eslint-plugin-yml": "^1.18.0",
105
105
  "gh-changelogen": "^0.2.8",
106
- "gunshi019": "npm:gunshi@0.22.0",
106
+ "gunshi019": "npm:gunshi@0.23.0",
107
107
  "jsr": "^0.13.4",
108
108
  "jsr-exports-lint": "^0.2.0",
109
109
  "knip": "^5.53.0",