Skip to content

Commit

Permalink
add examples to the usage page
Browse files Browse the repository at this point in the history
  • Loading branch information
taravancil committed Dec 8, 2016
1 parent 9c6ef42 commit 2ea9bec
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
7 changes: 5 additions & 2 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 7,11 @@ export default class Command {
}

help () {
console.log(`${bold('shroud-cli ' this.name)}\n${this.usage}\nOptions:\n`
`${this.options}\nExamples:\n${this.examples}`)
console.log(`${bold('shroud-cli ' this.name)}`)
console.log(`${this.usage}\n\nOptions:\n${this.options}`)

console.log('Examples:\n')
this.examples.forEach(example => console.log(example))
}

run (args) {
Expand Down
6 changes: 5 additions & 1 deletion lib/commands/add.js
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
// external
import Shroud from 'shroud'
import inquirer from 'inquirer'
import {red, green} from 'chalk'
import {red, green, blue} from 'chalk'

// lib
import Command from '../command'
Expand Down Expand Up @@ -55,6 55,10 @@ const add = {
name: 'add',
usage: '<add> secret-name [options]',
options: [],
examples: [
`Add a secret to the vault\n\n${blue('shroud add github.com\n')}`,
`Add a secret to the vault under a category\n\n${blue('shroud add github.com --category work\n')}`
],
command: command
}

Expand Down
5 changes: 4 additions & 1 deletion lib/commands/init.js
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
// external
import Shroud from 'shroud'
import inquirer from 'inquirer'
import {red, green} from 'chalk'
import {blue, red, green} from 'chalk'

// lib
import Command from '../command'
Expand Down Expand Up @@ -38,6 38,9 @@ const command = async function (args) {
const init = {
name: 'init',
usage: '<init>',
examples: [
`Initialize shroud\n\n${blue('shroud init\n')}`
],
options: [],
command: command
}
Expand Down
5 changes: 5 additions & 0 deletions lib/commands/list.js
Original file line number Diff line number Diff line change
@@ -1,5 1,6 @@
// external
import Shroud from 'shroud'
import {blue} from 'chalk'

// lib
import Command from '../command'
Expand All @@ -23,6 24,10 @@ const command = async function (args) {
const list = {
name: 'list',
usage: '<ls | list> [options]',
// TODO add example with category and pattern matching -tbv
examples: [
`List all of the secrets in the vault\n\n${blue('shroud ls\n')}`,
],
options: [],
command: command
}
Expand Down
6 changes: 5 additions & 1 deletion lib/commands/remove.js
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
// external
import Shroud from 'shroud'
import {green, red} from 'chalk'
import {green, red, blue} from 'chalk'

// lib
import Command from '../command'
Expand Down Expand Up @@ -36,6 36,10 @@ const command = async function (args) {
const remove = {
name: 'remove',
usage: '<rm | remove> secret-name [options]',
examples: [
`Remove a secret\n\n${blue('shroud rm github.com\n')}`,
`Remove a secret from a category\n\n${blue('shroud rm github.com --category work\n')}`
],
options: [],
command: command
}
Expand Down
6 changes: 5 additions & 1 deletion lib/commands/show.js
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
// external
import Shroud from 'shroud'
import inquirer from 'inquirer'
import {bold, red, green} from 'chalk'
import {bold, blue, red, green} from 'chalk'
import {copy} from 'copy-paste'

// lib
Expand Down Expand Up @@ -44,6 44,10 @@ const command = async function (args) {
const show = {
name: 'show',
usage: '<show> secret-name [options]',
examples: [
`Show a secret\n\n${blue('shroud show github.com\n')}`,
`Show a secret from a specific category\n\n${blue('shroud show --category github.com\n')}`
],
options: [],
command: command
}
Expand Down
7 changes: 5 additions & 2 deletions lib/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 4,18 @@ import {bold} from 'chalk'
import commands from './commands/index'

export default function () {
console.log(bold('Usage:'))
console.log(bold('Usage:\n'))
console.log('shroud-cli <command> [options]\n')

// TODO what's up with this? -tbv
const _commands = commands._c

let examples = []
for (const [name, command] of _commands) {
console.log(`${name}:\t${command.usage}`)
examples = examples.concat(command.examples)
}

// TODO add examples -tbv
console.log(bold('\nExamples:\n'))
examples.forEach(example => console.log(example))
}

0 comments on commit 2ea9bec

Please sign in to comment.