Gathering detailed insights and metrics for @oclif/core
Gathering detailed insights and metrics for @oclif/core
Gathering detailed insights and metrics for @oclif/core
Gathering detailed insights and metrics for @oclif/core
npm install @oclif/core
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
208 Stars
1,418 Commits
70 Forks
7 Watching
6 Branches
56 Contributors
Updated on 26 Nov 2024
TypeScript (99.43%)
JavaScript (0.57%)
Cumulative downloads
Total Downloads
Last day
-7.2%
444,705
Compared to previous day
Last week
-0.6%
2,565,094
Compared to previous week
Last month
2.2%
11,068,928
Compared to previous month
Last year
68.7%
117,230,673
Compared to previous year
18
39
This is a framework for building CLIs in Node.js. This framework was built out of the Salesforce CLI but generalized to build any custom CLI. It's designed both for single-file CLIs with a few flag options (like cat
or ls
), or for very complex CLIs that have subcommands (like git
or heroku
).
See the docs for more information.
The Getting Started tutorial is a step-by-step guide to introduce you to oclif. If you have not developed anything in a command line before, this tutorial is a great place to get started.
--help
to the CLI to get help such as flag options and argument information. This information is also automatically placed in the README whenever the npm package of the CLI is published. See the hello-world CLI examplets-node
to run the plugins enabling you to use TypeScript with minimal-to-no boilerplate needed for any oclif CLI.$ heroku info --app=<tab><tab> # will complete with all the Heroku apps a user has in their account
Currently, Node 18+ is supported. We support the LTS versions of Node. You can add the node package to your CLI to ensure users are running a specific version of Node.
See the v3 migration guide for an overview of breaking changes that occurred between v2 and v3.
See the v2 migration guide for an overview of breaking changes that occurred between v1 and v2.
Migrating from @oclif/config
and @oclif/command
? See the v1 migration guide.
The official oclif website, oclif.io, contains all the documentation you need for developing a CLI with oclif.
If there's anything you'd like to see in the documentation, please submit an issue on the oclif.github.io repo.
We strongly encourage you generate an oclif CLI using the oclif cli. The generator will generate an npm package with @oclif/core
as a dependency.
You can, however, use @oclif/core
in a standalone script like this:
1#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning 2 3import * as fs from 'fs' 4import {Command, Flags, flush, handle} from '@oclif/core' 5 6class LS extends Command { 7 static description = 'List the files in a directory.' 8 static flags = { 9 version: Flags.version(), 10 help: Flags.help(), 11 dir: Flags.string({ 12 char: 'd', 13 default: process.cwd(), 14 }), 15 } 16 17 async run() { 18 const {flags} = await this.parse(LS) 19 const files = fs.readdirSync(flags.dir) 20 for (const f of files) { 21 this.log(f) 22 } 23 } 24} 25 26LS.run().then( 27 async () => { 28 await flush() 29 }, 30 async (err) => { 31 await handle(err) 32 }, 33)
Then run it like this:
1$ ts-node myscript.ts 2...files in current dir...
You can also use oclif's Parser
separately:
1// index.js 2import {Args, Flags, Parser} from '@oclif/core' 3 4const {args, flags} = await Parser.parse(process.argv.slice(2), { 5 args: { 6 name: Args.string({required: true}), 7 }, 8 flags: { 9 from: Flags.string({char: 'f', default: 'oclif'}), 10 }, 11}) 12 13console.log(`hello ${args.name} from ${flags.form}`)
$ node index.js world --from oclif
hello world from oclif
🚀 Contributing
See the contributing guide.
No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
7 existing vulnerabilities detected
Details
Reason
Found 2/9 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More