From 501c4e97b71294126280a48cdb926993731c6143 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Wed, 24 Jul 2024 15:20:37 -0600 Subject: [PATCH] chore: update readme --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index c24c93b7b..fb1041616 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,30 @@ $ ts-node myscript.ts ...files in current dir... ``` +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).