Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/cli/parse-args/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// trigger skipped CI checks

Check failure on line 1 in lib/node_modules/@stdlib/cli/parse-args/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Trailing spaces not allowed

Check failure on line 1 in lib/node_modules/@stdlib/cli/parse-args/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

JSDoc comment for main export is missing `@module @stdlib/cli/parse-args` tag

Check warning on line 1 in lib/node_modules/@stdlib/cli/parse-args/lib/index.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Comments should begin with an uppercase character
44 changes: 44 additions & 0 deletions lib/node_modules/@stdlib/cli/parse-args/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';

function parseArgs(args, opts) {
var result = {
_: []
};

var i = 0;

while (i < args.length) {
var arg = args[i];

if (arg.startsWith('--') && arg.includes('=')) {
var parts = arg.slice(2).split('=');
result[parts[0]] = parts[1];

} else if (arg.startsWith('--')) {
var key = arg.slice(2);
var next = args[i + 1];

if (next && !next.startsWith('-')) {
result[key] = next;
i++;
} else {
result[key] = true;
}

} else if (arg.startsWith('-')) {
var flags = arg.slice(1).split('');
for (var j = 0; j < flags.length; j++) {
result[flags[j]] = true;
}

} else {
result._.push(arg);
}

i++;
}

return result;
}

module.exports = parseArgs;
1 change: 1 addition & 0 deletions lib/node_modules/@stdlib/cli/parse-args/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"@stdlib/cli/parse-args","version":"0.0.1","main":"lib/main.js"}
Loading