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 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!')
})
}
View state.js
let { questions, state: answered } = read()
questions
 .map(({ question, options }, i) => ({ 
  // …
  when(state){
  if (answered.hasOwnProperty(i)) {
  return false
  }
 
save(state)
View inquirer.js
const inquirer = require('inquirer')
const questions = require(questionsFile)
.map(({
question,
options
}, i) => ({  
type: 'list',
message: question,
choices: options,
name: `${i}`,
View prompt.js
const { promisify } = require('util')
const prompt = require('prompt')
const get = promisify(prompt.get)
function start() {
prompt.start()
get(
questions
.map(({ question }, i) => ({ name: `${i}`, description: question }))
View start.js
const { configure, start } = require('./commands')
program
  .command('start')
.description('start a quiz')
  .action(start)
You can’t perform that action at this time.