@oclif/core 4.0.14 → 4.0.15

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/README.md CHANGED
@@ -101,6 +101,30 @@ $ ts-node myscript.ts
101
101
  ...files in current dir...
102
102
  ```
103
103
 
104
+ You can also use oclif's `Parser` separately:
105
+
106
+ ```javascript
107
+ // index.js
108
+ import {Args, Flags, Parser} from '@oclif/core'
109
+
110
+ const {args, flags} = await Parser.parse(process.argv.slice(2), {
111
+ args: {
112
+ name: Args.string({required: true}),
113
+ },
114
+ flags: {
115
+ from: Flags.string({char: 'f', default: 'oclif'}),
116
+ },
117
+ })
118
+
119
+ console.log(`hello ${args.name} from ${flags.form}`)
120
+ ```
121
+
122
+ ```
123
+ $ node index.js world --from oclif
124
+
125
+ hello world from oclif
126
+ ```
127
+
104
128
  🚀 Contributing
105
129
 
106
130
  See the [contributing guide](./CONRTIBUTING.md).
@@ -303,13 +303,18 @@ class Parser {
303
303
  }
304
304
  // multiple with custom delimiter
305
305
  if (fws.inputFlag.flag.type === 'option' && fws.inputFlag.flag.delimiter && fws.inputFlag.flag.multiple) {
306
+ // regex that will identify unescaped delimiters
307
+ const makeDelimiter = (delimiter) => new RegExp(`(?<!\\\\)${delimiter}`);
306
308
  return {
307
309
  ...fws,
308
310
  valueFunction: async (i) => (await Promise.all((i.tokens ?? [])
309
- .flatMap((token) => token.input.split(i.inputFlag.flag.delimiter ?? ','))
311
+ .flatMap((token) => token.input.split(makeDelimiter(i.inputFlag.flag.delimiter ?? ',')))
310
312
  // trim, and remove surrounding doubleQuotes (which would hav been needed if the elements contain spaces)
311
313
  .map((v) => v
312
314
  .trim()
315
+ // remove escaped characters from delimiter
316
+ // example: --opt="a\,b,c" -> ["a,b", "c"]
317
+ .replaceAll(new RegExp(`\\\\${i.inputFlag.flag.delimiter}`, 'g'), i.inputFlag.flag.delimiter ?? ',')
313
318
  .replace(/^"(.*)"$/, '$1')
314
319
  .replace(/^'(.*)'$/, '$1'))
315
320
  .map(async (v) => parseFlagOrThrowError(v, i.inputFlag.flag, this.context, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "4.0.14",
4
+ "version": "4.0.15",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {