@trenskow/arguments-parser 0.1.6 → 0.1.8

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 +7 -4
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ import print from '@trenskow/print';
14
14
 
15
15
  export default (args = process.argv.slice(2), argvLevel = 0) => {
16
16
 
17
- const baseArguments = `${process.argv.slice(1, argvLevel + 2).map(((arg) => basename(arg))).join(' ')}`;
17
+ const base = `${process.argv.slice(1, argvLevel + 2).map(((arg) => basename(arg))).join(' ')}`;
18
18
 
19
19
  const list = (items) => {
20
20
 
@@ -30,12 +30,15 @@ export default (args = process.argv.slice(2), argvLevel = 0) => {
30
30
  };
31
31
 
32
32
  return {
33
+ get base() {
34
+ return base;
35
+ },
33
36
  command: async (commands) => {
34
37
 
35
38
  const printHelp = (error) => {
36
39
 
37
40
  print();
38
- print(`Usage: ${baseArguments} [command]`);
41
+ print(`Usage: ${base} [command]`);
39
42
  print();
40
43
  print('Available commands:');
41
44
  print();
@@ -69,7 +72,7 @@ export default (args = process.argv.slice(2), argvLevel = 0) => {
69
72
  if (!commands[tool]) printHelp(new Error(`${args[0]}: Command not found.`));
70
73
 
71
74
  try {
72
- await commands[tool](...args.slice(1));
75
+ return await commands[tool](...args.slice(1));
73
76
  } catch (error) {
74
77
  print.err(`${error.stack}`);
75
78
  process.exit(1);
@@ -111,7 +114,7 @@ export default (args = process.argv.slice(2), argvLevel = 0) => {
111
114
  }
112
115
 
113
116
  print();
114
- print.nn(`Usage: ${baseArguments} [options]`);
117
+ print.nn(`Usage: ${base} [options]`);
115
118
 
116
119
  if (options.help?.postfix) print.nn(options.help.postfix);
117
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trenskow/arguments-parser",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Yet another arguments parser.",
5
5
  "main": "index.js",
6
6
  "type": "module",