cli-argv-util 0.0.1 → 0.1.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.
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Individual contributors to cli-argv-util
3
+ Copyright (c) 2022-2023 Individual contributors to cli-argv-util
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -19,7 +19,7 @@ $ npm install cli-argv-util
19
19
  ```
20
20
 
21
21
  ## B) Usage
22
- Enter the following code in your **bin/cli.js** file
22
+ Place the following code in your **bin/cli.js** file
23
23
  ```javascript
24
24
  import { cliArgvUtil } from 'cli-argv-util';
25
25
 
@@ -1,4 +1,4 @@
1
- //! cli-argv-util v0.0.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
1
+ //! cli-argv-util v0.1.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
2
2
 
3
3
  export type StringFlagMap = {
4
4
  [flag: string]: string | undefined;
@@ -12,6 +12,7 @@ export type Result = {
12
12
  invalidFlag: string | null;
13
13
  invalidFlagMsg: string | null;
14
14
  params: string[];
15
+ paramCount: number;
15
16
  };
16
17
  declare const cliArgvUtil: {
17
18
  parse(validFlags: string[]): Result;
@@ -1,4 +1,4 @@
1
- //! cli-argv-util v0.0.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
1
+ //! cli-argv-util v0.1.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
2
2
 
3
3
  const cliArgvUtil = {
4
4
  parse(validFlags) {
@@ -12,12 +12,14 @@ const cliArgvUtil = {
12
12
  const onEntries = validFlags.map(flag => [toCamel(flag), toCamel(flag) in flagMap]);
13
13
  const invalidFlag = (_b = (_a = pairs.find(pair => !validFlags.includes(pair[0]))) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
14
14
  const helpMsg = '\nValid flags are --' + validFlags.join(' --');
15
+ const params = args.filter(arg => !/^--/.test(arg));
15
16
  return {
16
17
  flagMap: flagMap,
17
18
  flagOn: Object.fromEntries(onEntries),
18
19
  invalidFlag: invalidFlag,
19
20
  invalidFlagMsg: invalidFlag ? 'Invalid flag: --' + invalidFlag + helpMsg : null,
20
- params: args.filter((arg) => !/^--/.test(arg)),
21
+ params: params,
22
+ paramCount: params.length,
21
23
  };
22
24
  },
23
25
  };
@@ -1,4 +1,4 @@
1
- //! cli-argv-util v0.0.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
1
+ //! cli-argv-util v0.1.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
2
2
 
3
3
  (function (factory) {
4
4
  if (typeof module === "object" && typeof module.exports === "object") {
@@ -24,12 +24,14 @@
24
24
  const onEntries = validFlags.map(flag => [toCamel(flag), toCamel(flag) in flagMap]);
25
25
  const invalidFlag = (_b = (_a = pairs.find(pair => !validFlags.includes(pair[0]))) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
26
26
  const helpMsg = '\nValid flags are --' + validFlags.join(' --');
27
+ const params = args.filter(arg => !/^--/.test(arg));
27
28
  return {
28
29
  flagMap: flagMap,
29
30
  flagOn: Object.fromEntries(onEntries),
30
31
  invalidFlag: invalidFlag,
31
32
  invalidFlagMsg: invalidFlag ? 'Invalid flag: --' + invalidFlag + helpMsg : null,
32
- params: args.filter((arg) => !/^--/.test(arg)),
33
+ params: params,
34
+ paramCount: params.length,
33
35
  };
34
36
  },
35
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-argv-util",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "description": "Simple utility to parse command line parameters and flags (arguments vector)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -74,15 +74,15 @@
74
74
  },
75
75
  "devDependencies": {
76
76
  "@types/node": "~18.11",
77
- "@typescript-eslint/eslint-plugin": "~5.43",
78
- "@typescript-eslint/parser": "~5.43",
77
+ "@typescript-eslint/eslint-plugin": "~5.49",
78
+ "@typescript-eslint/parser": "~5.49",
79
79
  "add-dist-header": "~0.3",
80
80
  "assert-deep-strict-equal": "~1.0",
81
81
  "copy-file-util": "~0.1",
82
- "eslint": "~8.27",
82
+ "eslint": "~8.32",
83
83
  "jshint": "~2.13",
84
- "mocha": "~10.1",
85
- "rimraf": "~3.0",
84
+ "mocha": "~10.2",
85
+ "rimraf": "~4.1",
86
86
  "run-scripts-util": "~0.1",
87
87
  "typescript": "~4.9"
88
88
  }