@oclif/core
Advanced tools
Comparing version 4.0.14 to 4.0.15
@@ -306,9 +306,14 @@ "use strict"; | ||
if (fws.inputFlag.flag.type === 'option' && fws.inputFlag.flag.delimiter && fws.inputFlag.flag.multiple) { | ||
// regex that will identify unescaped delimiters | ||
const makeDelimiter = (delimiter) => new RegExp(`(?<!\\\\)${delimiter}`); | ||
return { | ||
...fws, | ||
valueFunction: async (i) => (await Promise.all((i.tokens ?? []) | ||
.flatMap((token) => token.input.split(i.inputFlag.flag.delimiter ?? ',')) | ||
.flatMap((token) => token.input.split(makeDelimiter(i.inputFlag.flag.delimiter ?? ','))) | ||
// trim, and remove surrounding doubleQuotes (which would hav been needed if the elements contain spaces) | ||
.map((v) => v | ||
.trim() | ||
// remove escaped characters from delimiter | ||
// example: --opt="a\,b,c" -> ["a,b", "c"] | ||
.replaceAll(new RegExp(`\\\\${i.inputFlag.flag.delimiter}`, 'g'), i.inputFlag.flag.delimiter ?? ',') | ||
.replace(/^"(.*)"$/, '$1') | ||
@@ -315,0 +320,0 @@ .replace(/^'(.*)'$/, '$1')) |
{ | ||
"name": "@oclif/core", | ||
"description": "base library for oclif CLIs", | ||
"version": "4.0.14", | ||
"version": "4.0.15", | ||
"author": "Salesforce", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/core/issues", |
@@ -104,4 +104,28 @@ <img src="https://user-images.githubusercontent.com/449385/38243295-e0a47d58-372e-11e8-9bc0-8c02a6f4d2ac.png" width="260" height="73"> | ||
You can also use oclif's `Parser` separately: | ||
```javascript | ||
// index.js | ||
import {Args, Flags, Parser} from '@oclif/core' | ||
const {args, flags} = await Parser.parse(process.argv.slice(2), { | ||
args: { | ||
name: Args.string({required: true}), | ||
}, | ||
flags: { | ||
from: Flags.string({char: 'f', default: 'oclif'}), | ||
}, | ||
}) | ||
console.log(`hello ${args.name} from ${flags.form}`) | ||
``` | ||
``` | ||
$ node index.js world --from oclif | ||
hello world from oclif | ||
``` | ||
🚀 Contributing | ||
See the [contributing guide](./CONRTIBUTING.md). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
399618
10063
131