breadc 0.1.0 → 0.3.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/dist/index.cjs CHANGED
@@ -3,38 +3,289 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const kolorist = require('kolorist');
6
- const minimist = require('minimist');
7
- const createDebug = require('debug');
8
6
 
9
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
10
8
 
11
9
  const kolorist__default = /*#__PURE__*/_interopDefaultLegacy(kolorist);
12
- const minimist__default = /*#__PURE__*/_interopDefaultLegacy(minimist);
13
- const createDebug__default = /*#__PURE__*/_interopDefaultLegacy(createDebug);
14
10
 
15
- function createDefaultLogger(name) {
16
- const debug = createDebug__default(name + ":breadc");
17
- return {
18
- println(message) {
19
- console.log(message);
20
- },
21
- info(message, ...args) {
22
- console.log(`${kolorist.blue("INFO")} ${message}`, ...args);
23
- },
24
- warn(message, ...args) {
25
- console.log(`${kolorist.yellow("WARN")} ${message}`, ...args);
26
- },
27
- error(message, ...args) {
28
- console.log(`${kolorist.red("ERROR")} ${message}`, ...args);
29
- },
30
- debug(message, ...args) {
31
- debug(message, ...args);
11
+ var minimist = function (args, opts) {
12
+ if (!opts) opts = {};
13
+
14
+ var flags = { bools : {}, strings : {}, unknownFn: null };
15
+
16
+ if (typeof opts['unknown'] === 'function') {
17
+ flags.unknownFn = opts['unknown'];
18
+ }
19
+
20
+ if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
21
+ flags.allBools = true;
22
+ } else {
23
+ [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
24
+ flags.bools[key] = true;
25
+ });
26
+ }
27
+
28
+ var aliases = {};
29
+ Object.keys(opts.alias || {}).forEach(function (key) {
30
+ aliases[key] = [].concat(opts.alias[key]);
31
+ aliases[key].forEach(function (x) {
32
+ aliases[x] = [key].concat(aliases[key].filter(function (y) {
33
+ return x !== y;
34
+ }));
35
+ });
36
+ });
37
+
38
+ [].concat(opts.string).filter(Boolean).forEach(function (key) {
39
+ flags.strings[key] = true;
40
+ if (aliases[key]) {
41
+ flags.strings[aliases[key]] = true;
42
+ }
43
+ });
44
+
45
+ var defaults = opts['default'] || {};
46
+
47
+ var argv = { _ : [] };
48
+ Object.keys(flags.bools).forEach(function (key) {
49
+ setArg(key, defaults[key] === undefined ? false : defaults[key]);
50
+ });
51
+
52
+ var notFlags = [];
53
+
54
+ if (args.indexOf('--') !== -1) {
55
+ notFlags = args.slice(args.indexOf('--')+1);
56
+ args = args.slice(0, args.indexOf('--'));
57
+ }
58
+
59
+ function argDefined(key, arg) {
60
+ return (flags.allBools && /^--[^=]+$/.test(arg)) ||
61
+ flags.strings[key] || flags.bools[key] || aliases[key];
62
+ }
63
+
64
+ function setArg (key, val, arg) {
65
+ if (arg && flags.unknownFn && !argDefined(key, arg)) {
66
+ if (flags.unknownFn(arg) === false) return;
67
+ }
68
+
69
+ var value = !flags.strings[key] && isNumber(val)
70
+ ? Number(val) : val
71
+ ;
72
+ setKey(argv, key.split('.'), value);
73
+
74
+ (aliases[key] || []).forEach(function (x) {
75
+ setKey(argv, x.split('.'), value);
76
+ });
32
77
  }
78
+
79
+ function setKey (obj, keys, value) {
80
+ var o = obj;
81
+ for (var i = 0; i < keys.length-1; i++) {
82
+ var key = keys[i];
83
+ if (isConstructorOrProto(o, key)) return;
84
+ if (o[key] === undefined) o[key] = {};
85
+ if (o[key] === Object.prototype || o[key] === Number.prototype
86
+ || o[key] === String.prototype) o[key] = {};
87
+ if (o[key] === Array.prototype) o[key] = [];
88
+ o = o[key];
89
+ }
90
+
91
+ var key = keys[keys.length - 1];
92
+ if (isConstructorOrProto(o, key)) return;
93
+ if (o === Object.prototype || o === Number.prototype
94
+ || o === String.prototype) o = {};
95
+ if (o === Array.prototype) o = [];
96
+ if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
97
+ o[key] = value;
98
+ }
99
+ else if (Array.isArray(o[key])) {
100
+ o[key].push(value);
101
+ }
102
+ else {
103
+ o[key] = [ o[key], value ];
104
+ }
105
+ }
106
+
107
+ function aliasIsBoolean(key) {
108
+ return aliases[key].some(function (x) {
109
+ return flags.bools[x];
110
+ });
111
+ }
112
+
113
+ for (var i = 0; i < args.length; i++) {
114
+ var arg = args[i];
115
+
116
+ if (/^--.+=/.test(arg)) {
117
+ // Using [\s\S] instead of . because js doesn't support the
118
+ // 'dotall' regex modifier. See:
119
+ // http://stackoverflow.com/a/1068308/13216
120
+ var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
121
+ var key = m[1];
122
+ var value = m[2];
123
+ if (flags.bools[key]) {
124
+ value = value !== 'false';
125
+ }
126
+ setArg(key, value, arg);
127
+ }
128
+ else if (/^--no-.+/.test(arg)) {
129
+ var key = arg.match(/^--no-(.+)/)[1];
130
+ setArg(key, false, arg);
131
+ }
132
+ else if (/^--.+/.test(arg)) {
133
+ var key = arg.match(/^--(.+)/)[1];
134
+ var next = args[i + 1];
135
+ if (next !== undefined && !/^-/.test(next)
136
+ && !flags.bools[key]
137
+ && !flags.allBools
138
+ && (aliases[key] ? !aliasIsBoolean(key) : true)) {
139
+ setArg(key, next, arg);
140
+ i++;
141
+ }
142
+ else if (/^(true|false)$/.test(next)) {
143
+ setArg(key, next === 'true', arg);
144
+ i++;
145
+ }
146
+ else {
147
+ setArg(key, flags.strings[key] ? '' : true, arg);
148
+ }
149
+ }
150
+ else if (/^-[^-]+/.test(arg)) {
151
+ var letters = arg.slice(1,-1).split('');
152
+
153
+ var broken = false;
154
+ for (var j = 0; j < letters.length; j++) {
155
+ var next = arg.slice(j+2);
156
+
157
+ if (next === '-') {
158
+ setArg(letters[j], next, arg);
159
+ continue;
160
+ }
161
+
162
+ if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
163
+ setArg(letters[j], next.split('=')[1], arg);
164
+ broken = true;
165
+ break;
166
+ }
167
+
168
+ if (/[A-Za-z]/.test(letters[j])
169
+ && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
170
+ setArg(letters[j], next, arg);
171
+ broken = true;
172
+ break;
173
+ }
174
+
175
+ if (letters[j+1] && letters[j+1].match(/\W/)) {
176
+ setArg(letters[j], arg.slice(j+2), arg);
177
+ broken = true;
178
+ break;
179
+ }
180
+ else {
181
+ setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
182
+ }
183
+ }
184
+
185
+ var key = arg.slice(-1)[0];
186
+ if (!broken && key !== '-') {
187
+ if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
188
+ && !flags.bools[key]
189
+ && (aliases[key] ? !aliasIsBoolean(key) : true)) {
190
+ setArg(key, args[i+1], arg);
191
+ i++;
192
+ }
193
+ else if (args[i+1] && /^(true|false)$/.test(args[i+1])) {
194
+ setArg(key, args[i+1] === 'true', arg);
195
+ i++;
196
+ }
197
+ else {
198
+ setArg(key, flags.strings[key] ? '' : true, arg);
199
+ }
200
+ }
201
+ }
202
+ else {
203
+ if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
204
+ argv._.push(
205
+ flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
206
+ );
207
+ }
208
+ if (opts.stopEarly) {
209
+ argv._.push.apply(argv._, args.slice(i + 1));
210
+ break;
211
+ }
212
+ }
213
+ }
214
+
215
+ Object.keys(defaults).forEach(function (key) {
216
+ if (!hasKey(argv, key.split('.'))) {
217
+ setKey(argv, key.split('.'), defaults[key]);
218
+
219
+ (aliases[key] || []).forEach(function (x) {
220
+ setKey(argv, x.split('.'), defaults[key]);
221
+ });
222
+ }
223
+ });
224
+
225
+ if (opts['--']) {
226
+ argv['--'] = new Array();
227
+ notFlags.forEach(function(key) {
228
+ argv['--'].push(key);
229
+ });
230
+ }
231
+ else {
232
+ notFlags.forEach(function(key) {
233
+ argv._.push(key);
234
+ });
235
+ }
236
+
237
+ return argv;
238
+ };
239
+
240
+ function hasKey (obj, keys) {
241
+ var o = obj;
242
+ keys.slice(0,-1).forEach(function (key) {
243
+ o = (o[key] || {});
244
+ });
245
+
246
+ var key = keys[keys.length - 1];
247
+ return key in o;
248
+ }
249
+
250
+ function isNumber (x) {
251
+ if (typeof x === 'number') return true;
252
+ if (/^0x[0-9a-f]+$/i.test(x)) return true;
253
+ return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
254
+ }
255
+
256
+
257
+ function isConstructorOrProto (obj, key) {
258
+ return key === 'constructor' && typeof obj[key] === 'function' || key === '__proto__';
259
+ }
260
+
261
+ function createDefaultLogger(name, logger) {
262
+ const println = !!logger && typeof logger === "function" ? logger : logger?.println ?? ((message, ...args) => {
263
+ console.log(message, ...args);
264
+ });
265
+ const info = typeof logger === "object" && logger?.info ? logger.info : (message, ...args) => {
266
+ println(`${kolorist.blue("INFO")} ${message}`, ...args);
267
+ };
268
+ const warn = typeof logger === "object" && logger?.warn ? logger.warn : (message, ...args) => {
269
+ println(`${kolorist.yellow("WARN")} ${message}`, ...args);
270
+ };
271
+ const error = typeof logger === "object" && logger?.error ? logger.error : (message, ...args) => {
272
+ println(`${kolorist.red("ERROR")} ${message}`, ...args);
273
+ };
274
+ const debug = typeof logger === "object" && logger?.debug ? logger.debug : (message, ...args) => {
275
+ println(`${kolorist.gray(name)} ${message}`, ...args);
276
+ };
277
+ return {
278
+ println,
279
+ info,
280
+ warn,
281
+ error,
282
+ debug
33
283
  };
34
284
  }
35
285
 
36
286
  const _Option = class {
37
287
  constructor(format, config = {}) {
288
+ this.format = format;
38
289
  const match = _Option.OptionRE.exec(format);
39
290
  if (match) {
40
291
  if (match[3]) {
@@ -50,25 +301,28 @@ const _Option = class {
50
301
  throw new Error(`Can not parse option format from "${format}"`);
51
302
  }
52
303
  this.description = config.description ?? "";
304
+ this.required = format.indexOf("<") !== -1;
305
+ this.default = config.default;
53
306
  this.construct = config.construct ?? ((text) => text ?? config.default ?? void 0);
54
307
  }
55
308
  };
56
309
  let Option = _Option;
57
310
  Option.OptionRE = /^(-[a-zA-Z], )?--([a-zA-Z.]+)( \[[a-zA-Z]+\]| <[a-zA-Z]+>)?$/;
58
311
 
59
- class Command {
312
+ const _Command = class {
60
313
  constructor(format, config) {
61
314
  this.options = [];
62
315
  this.format = config.condition ? [format] : format.split(" ").map((t) => t.trim()).filter(Boolean);
316
+ this.default = this.format.length === 0 || this.format[0][0] === "[" || this.format[0][0] === "<";
63
317
  this.description = config.description ?? "";
64
318
  this.conditionFn = config.condition;
65
319
  this.logger = config.logger;
320
+ if (this.format.length > _Command.MaxDep) {
321
+ this.logger.warn(`Command format string "${format}" is too long`);
322
+ }
66
323
  }
67
324
  option(format, configOrDescription = "", otherConfig = {}) {
68
- const config = otherConfig;
69
- if (typeof configOrDescription === "string") {
70
- config.description = configOrDescription;
71
- }
325
+ const config = typeof configOrDescription === "object" ? configOrDescription : { ...otherConfig, description: configOrDescription };
72
326
  try {
73
327
  const option = new Option(format, config);
74
328
  this.options.push(option);
@@ -77,13 +331,18 @@ class Command {
77
331
  }
78
332
  return this;
79
333
  }
334
+ get hasConditionFn() {
335
+ return !!this.conditionFn;
336
+ }
80
337
  shouldRun(args) {
81
338
  if (this.conditionFn) {
82
339
  return this.conditionFn(args);
83
340
  } else {
84
- const isArg = (t) => t[0] !== "[" && t[0] !== "<";
341
+ if (this.default)
342
+ return true;
343
+ const isCmd = (t) => t[0] !== "[" && t[0] !== "<";
85
344
  for (let i = 0; i < this.format.length; i++) {
86
- if (isArg(this.format[i])) {
345
+ if (!isCmd(this.format[i])) {
87
346
  return true;
88
347
  }
89
348
  if (i >= args["_"].length || this.format[i] !== args["_"][i]) {
@@ -93,7 +352,7 @@ class Command {
93
352
  return true;
94
353
  }
95
354
  }
96
- parseArgs(args) {
355
+ parseArgs(args, globalOptions) {
97
356
  if (this.conditionFn) {
98
357
  const argumentss2 = args["_"];
99
358
  const options2 = args;
@@ -104,33 +363,55 @@ class Command {
104
363
  options: args
105
364
  };
106
365
  }
107
- const isArg = (t) => t[0] !== "[" && t[0] !== "<";
366
+ const isCmd = (t) => t[0] !== "[" && t[0] !== "<";
108
367
  const argumentss = [];
109
368
  for (let i = 0; i < this.format.length; i++) {
110
- if (isArg(this.format[i]))
369
+ if (isCmd(this.format[i]))
111
370
  continue;
112
371
  if (i < args["_"].length) {
113
372
  if (this.format[i].startsWith("[...")) {
114
- argumentss.push(args["_"].slice(i));
373
+ argumentss.push(args["_"].slice(i).map(String));
115
374
  } else {
116
- argumentss.push(args["_"][i]);
375
+ argumentss.push(String(args["_"][i]));
117
376
  }
118
377
  } else {
119
378
  if (this.format[i].startsWith("<")) {
379
+ this.logger.warn(`You should provide the argument "${this.format[i]}"`);
120
380
  argumentss.push(void 0);
121
381
  } else if (this.format[i].startsWith("[...")) {
122
382
  argumentss.push([]);
123
383
  } else if (this.format[i].startsWith("[")) {
124
384
  argumentss.push(void 0);
125
- } else ;
385
+ } else {
386
+ this.logger.warn(`unknown format string ("${this.format[i]}")`);
387
+ }
126
388
  }
127
389
  }
390
+ const fullOptions = globalOptions.concat(this.options).reduce((map, o) => {
391
+ map.set(o.name, o);
392
+ return map;
393
+ }, /* @__PURE__ */ new Map());
128
394
  const options = args;
129
395
  delete options["_"];
396
+ for (const [name, rawOption] of fullOptions) {
397
+ if (rawOption.required) {
398
+ if (options[name] === void 0) {
399
+ options[name] = false;
400
+ } else if (options[name] === "") {
401
+ options[name] = true;
402
+ }
403
+ } else {
404
+ if (options[name] === false) {
405
+ options[name] = void 0;
406
+ } else if (!(name in options)) {
407
+ options[name] = void 0;
408
+ }
409
+ }
410
+ }
130
411
  return {
131
412
  command: this,
132
413
  arguments: argumentss,
133
- options: args
414
+ options
134
415
  };
135
416
  }
136
417
  action(fn) {
@@ -138,17 +419,29 @@ class Command {
138
419
  return this;
139
420
  }
140
421
  async run(...args) {
141
- this.actionFn && this.actionFn(...args);
422
+ if (this.actionFn) {
423
+ this.actionFn(...args);
424
+ } else {
425
+ this.logger.warn(`You may miss action function in "${this.format}"`);
426
+ }
142
427
  }
143
- }
144
- Command.MaxDep = 4;
145
- function createVersionCommand(breadc) {
428
+ };
429
+ let Command = _Command;
430
+ Command.MaxDep = 5;
431
+ function createHelpCommand(breadc) {
432
+ let helpCommand = void 0;
146
433
  return new Command("-h, --help", {
147
434
  condition(args) {
148
- const isEmpty = !args["_"].length && !args["--"]?.length;
149
- if (args.help && isEmpty) {
150
- return true;
151
- } else if (args.h && isEmpty) {
435
+ const isEmpty = !args["--"]?.length;
436
+ if ((args.help || args.h) && isEmpty) {
437
+ if (args["_"].length > 0) {
438
+ for (const cmd of breadc.commands) {
439
+ if (!cmd.hasConditionFn && !cmd.default && cmd.shouldRun(args)) {
440
+ helpCommand = cmd;
441
+ return true;
442
+ }
443
+ }
444
+ }
152
445
  return true;
153
446
  } else {
154
447
  return false;
@@ -156,10 +449,12 @@ function createVersionCommand(breadc) {
156
449
  },
157
450
  logger: breadc.logger
158
451
  }).action(() => {
159
- breadc.logger.println("Help");
452
+ for (const line of breadc.help(helpCommand)) {
453
+ breadc.logger.println(line);
454
+ }
160
455
  });
161
456
  }
162
- function createHelpCommand(breadc) {
457
+ function createVersionCommand(breadc) {
163
458
  return new Command("-v, --version", {
164
459
  condition(args) {
165
460
  const isEmpty = !args["_"].length && !args["--"]?.length;
@@ -173,7 +468,7 @@ function createHelpCommand(breadc) {
173
468
  },
174
469
  logger: breadc.logger
175
470
  }).action(() => {
176
- breadc.logger.println(`${breadc.name}/${breadc.version}`);
471
+ breadc.logger.println(breadc.version());
177
472
  });
178
473
  }
179
474
 
@@ -182,22 +477,78 @@ class Breadc {
182
477
  this.options = [];
183
478
  this.commands = [];
184
479
  this.name = name;
185
- this.version = option.version ?? "unknown";
186
- this.logger = option.logger ?? createDefaultLogger(name);
480
+ this._version = option.version ?? "unknown";
481
+ this.description = option.description;
482
+ this.logger = createDefaultLogger(name, option.logger);
187
483
  const breadc = {
188
484
  name: this.name,
189
- version: this.version,
485
+ version: () => this.version.call(this),
486
+ help: (command) => this.help.call(this, command),
190
487
  logger: this.logger,
191
488
  options: this.options,
192
489
  commands: this.commands
193
490
  };
194
- this.commands = [createVersionCommand(breadc), createHelpCommand(breadc)];
491
+ this.commands.push(createVersionCommand(breadc), createHelpCommand(breadc));
195
492
  }
196
- option(format, configOrDescription = "", otherConfig = {}) {
197
- const config = otherConfig;
198
- if (typeof configOrDescription === "string") {
199
- config.description = configOrDescription;
493
+ version() {
494
+ return `${this.name}/${this._version}`;
495
+ }
496
+ help(command) {
497
+ const output = [];
498
+ const println = (msg) => output.push(msg);
499
+ println(this.version());
500
+ if (!command) {
501
+ if (this.description) {
502
+ println("");
503
+ if (Array.isArray(this.description)) {
504
+ for (const line of this.description) {
505
+ println(line);
506
+ }
507
+ } else {
508
+ println(this.description);
509
+ }
510
+ }
511
+ } else {
512
+ if (command.description) {
513
+ println("");
514
+ println(command.description);
515
+ }
516
+ }
517
+ if (!command) {
518
+ if (this.defaultCommand) {
519
+ println(``);
520
+ println(`Usage:`);
521
+ println(` $ ${this.name} ${this.defaultCommand.format.join(" ")}`);
522
+ }
523
+ } else {
524
+ println(``);
525
+ println(`Usage:`);
526
+ println(` $ ${this.name} ${command.format.join(" ")}`);
527
+ }
528
+ if (!command && this.commands.length > 2) {
529
+ println(``);
530
+ println(`Commands:`);
531
+ const commandHelps = this.commands.filter((c) => !c.hasConditionFn).map((c) => [` $ ${this.name} ${c.format.join(" ")}`, c.description]);
532
+ for (const line of twoColumn(commandHelps)) {
533
+ println(line);
534
+ }
535
+ }
536
+ println(``);
537
+ println(`Options:`);
538
+ const optionHelps = [].concat([
539
+ ...command ? command.options.map((o) => [` ${o.format}`, o.description]) : [],
540
+ ...this.options.map((o) => [` ${o.format}`, o.description]),
541
+ [` -h, --help`, `Display this message`],
542
+ [` -v, --version`, `Display version number`]
543
+ ]);
544
+ for (const line of twoColumn(optionHelps)) {
545
+ println(line);
200
546
  }
547
+ println(``);
548
+ return output;
549
+ }
550
+ option(format, configOrDescription = "", otherConfig = {}) {
551
+ const config = typeof configOrDescription === "object" ? configOrDescription : { ...otherConfig, description: configOrDescription };
201
552
  try {
202
553
  const option = new Option(format, config);
203
554
  this.options.push(option);
@@ -206,32 +557,64 @@ class Breadc {
206
557
  }
207
558
  return this;
208
559
  }
209
- command(format, config = {}) {
560
+ command(format, configOrDescription = "", otherConfig = {}) {
561
+ const config = typeof configOrDescription === "object" ? configOrDescription : { ...otherConfig, description: configOrDescription };
210
562
  const command = new Command(format, { ...config, logger: this.logger });
563
+ if (command.default) {
564
+ if (this.defaultCommand) {
565
+ this.logger.warn("You can not have two default commands.");
566
+ }
567
+ this.defaultCommand = command;
568
+ }
211
569
  this.commands.push(command);
212
570
  return command;
213
571
  }
214
572
  parse(args) {
215
- const allowOptions = [this.options, this.commands.map((c) => c.options)].flat();
573
+ const allowOptions = [
574
+ ...this.options,
575
+ ...this.commands.flatMap((c) => c.options)
576
+ ];
216
577
  const alias = allowOptions.reduce((map, o) => {
217
578
  if (o.shortcut) {
218
579
  map[o.shortcut] = o.name;
219
580
  }
220
581
  return map;
221
582
  }, {});
222
- const argv = minimist__default(args, {
583
+ const defaults = allowOptions.reduce((map, o) => {
584
+ if (o.default) {
585
+ map[o.name] = o.default;
586
+ }
587
+ return map;
588
+ }, {});
589
+ const argv = minimist(args, {
223
590
  string: allowOptions.filter((o) => o.type === "string").map((o) => o.name),
224
591
  boolean: allowOptions.filter((o) => o.type === "boolean").map((o) => o.name),
225
- alias
592
+ alias,
593
+ default: defaults,
594
+ unknown: (t) => {
595
+ if (t[0] !== "-")
596
+ return true;
597
+ else {
598
+ if (["--help", "-h", "--version", "-v"].includes(t)) {
599
+ return true;
600
+ } else {
601
+ this.logger.warn(`Find unknown flag "${t}"`);
602
+ return false;
603
+ }
604
+ }
605
+ }
226
606
  });
227
607
  for (const shortcut of Object.keys(alias)) {
228
608
  delete argv[shortcut];
229
609
  }
230
610
  for (const command of this.commands) {
231
- if (command.shouldRun(argv)) {
232
- return command.parseArgs(argv);
611
+ if (!command.default && command.shouldRun(argv)) {
612
+ return command.parseArgs(argv, this.options);
233
613
  }
234
614
  }
615
+ if (this.defaultCommand) {
616
+ return this.defaultCommand.parseArgs(argv, this.options);
617
+ }
235
618
  const argumentss = argv["_"];
236
619
  const options = argv;
237
620
  delete options["_"];
@@ -248,12 +631,19 @@ class Breadc {
248
631
  }
249
632
  }
250
633
  }
634
+ function twoColumn(texts, split = " ") {
635
+ const left = padRight(texts.map((t) => t[0]));
636
+ return left.map((l, idx) => l + split + texts[idx][1]);
637
+ }
638
+ function padRight(texts, fill = " ") {
639
+ const length = texts.map((t) => t.length).reduce((max, l) => Math.max(max, l), 0);
640
+ return texts.map((t) => t + fill.repeat(length - t.length));
641
+ }
251
642
 
252
643
  function breadc(name, option = {}) {
253
644
  return new Breadc(name, option);
254
645
  }
255
646
 
256
647
  exports.kolorist = kolorist__default;
257
- exports.minimist = minimist__default;
258
- exports.createDebug = createDebug__default;
259
648
  exports["default"] = breadc;
649
+ exports.minimist = minimist;