Skip to content

Commit

Permalink
[add] new index to work with yargs
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryTabima committed Nov 30, 2018
1 parent 815942c commit d9aa76e
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict'

const yargs = require('yargs')
const generate = require('./cmds/generate')

function main () {
yargs
.usage('$0 <cmd> [args]')
// Default command 'generate'
.command({
command: 'generate [options]',
aliases: ['gen', 'g', '$0'], // $0 is to set this command as default. This commmand runs when no commans are passed
desc: 'Generate the md files',
handler: generate,
builder: (yargs) => {
yargs
.options({
'source': {
alias: 's',
default: './src',
desc: 'Source folder with .js or .ts files',
type: 'string'
},
'dist': {
alias: 'd',
default: './documentation',
desc: 'Destination folder',
type: 'string'
},
'folder': {
alias: 'f',
default: 'code',
desc: 'Folder inside destination folder. Gets overwritten everytime',
type: 'string'
},
'title': {
alias: 't',
default: 'API',
desc: 'Title of your documentation',
type: 'string'
}
})
},
})
// adding aliases to help and version args
.alias('help', 'h')
.alias('version', 'v')
.argv
}

module.exports = main

0 comments on commit d9aa76e

Please sign in to comment.