Skip to content

Instantly share code, notes, and snippets.

korzio

Block or report user

Report or block korzio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View oclif hook generate.sh
oclif hook commit --event=commit
cat src/hooks/commit/commit.ts
import {Hook} from '@oclif/config'
const hook: Hook<'commit'> = async function (opts) {
process.stdout.write(`example hook running ${opts.id}\n`)
}
export default hook
View oclif package.json
"oclif": {
"bin": "web",
"commands": "./lib/commands",
"plugins": [
"@oclif/plugin-help"
],
"scope": "ing-web-cli",
"hooks": {
"init": "./src/hooks/init/myhook"
}
View add.ts
import {Command, flags} from '@oclif/command'
import {existsSync, writeFileSync} from 'fs'
export default class Add extends Command {
static description = 'add new note'
static flags = {
help: flags.help({char: 'h'}),
}
View generate my oclif package.sh
mkdir my-oclif # create new source folder
cd my-oclif # locate to source folder
npm init -f # init empty npm package
npx oclif # ensure oclif can help
npx oclif multi # generate or scaffold multi command oclif application
View oclif generate output.sh
➜ my-oclif git:(master) ✗ npx oclif multi
npx: installed 442 in 9.042s
_-----_ ╭──────────────────────────╮
| | │ Time to build a │
|--(o)--| │ multi-command CLI with │
`---------´ │ oclif! Version: 1.13.1 │
( _´U`_ ) ╰──────────────────────────╯
/___A___\ /
| ~ |
View oclif generated folders structure.sh
tree . -L 1
.
├── README.md
├── bin
├── node_modules
├── package-lock.json
├── package.json
├── src
├── test
├── tsconfig.json
View my-oclif.sh
> npm link
> my-oclif
A markdown notes CLI example
VERSION
my-oclif/1.0.0 darwin-x64 node-v8.16.0
USAGE
$ my-oclif [COMMAND]
View try.sh
quizme configure ./test/mocks/questions.js
quizme start
View figlet.log
___ _ _ _
/ _ \ _ _(_)_____ __ ___ ___| | |
| | | | | | | |_ / '_ ` _ \ / _ \ | |
| |_| | |_| | |/ /| | | | | | __/_|_|
\__\_\\__,_|_/___|_| |_| |_|\___(_|_)
View result.js
function start() {
inquirer.prompt(questions)
.then((result) => {
save(result)
console.log(`Your asnwers: ${JSON.stringify(read().state)}`)
console.log('Thanks for participating!')
})
}
You can’t perform that action at this time.