Skip to content

Commit

Permalink
add help command, closes #55
Browse files Browse the repository at this point in the history
  • Loading branch information
joehand committed Jan 3, 2017
1 parent 9bf8237 commit 6b6fcbd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ var config = {
require('../lib/commands/auth/register'),
require('../lib/commands/auth/whoami'),
require('../lib/commands/auth/logout'),
require('../lib/commands/auth/login')
require('../lib/commands/auth/login'),
{
name: 'help',
command: require('../lib/usage')
}
],
aliases: {
'init': 'create'
Expand Down
3 changes: 2 additions & 1 deletion lib/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ module.exports = function (opts) {
console.error('Usage: dat-next <cmd> [options]')
console.error(' dat-next create create a local dat')
console.error(' dat-next snapshot create a local dat snapshot')
console.error(' dat-next sync sync latest files with the network. archive owners import updated files to share.')
console.error(' dat-next sync sync latest files with the network.')
console.error(' dat-next clone <dat-link> <directory> clone a remote dat')
console.error(' dat-next pull download updated files from a remote dat and exit')
console.error(' dat-next doctor run the dat network doctor')
console.error(' dat-next register register for an account')
console.error(' dat-next login login to an account')
console.error(' dat-next --version,-v get your dat-next version')
console.error(' dat-next help print this usage guide')
console.error('')
console.error(' --dir=<folder> set directory (all commands)')
console.error(' --no-import do not import files (create, sync)')
Expand Down
16 changes: 13 additions & 3 deletions tests/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var spawn = require('./helpers/spawn.js')
var dat = path.resolve(path.join(__dirname, '..', 'bin', 'cli.js'))
var version = require('../package.json').version

test('misc - prints usage', function (t) {
test('usage - prints usage', function (t) {
var d = spawn(t, dat)
d.stderr.match(function (output) {
var usage = output.indexOf('Usage') > -1
Expand All @@ -15,7 +15,7 @@ test('misc - prints usage', function (t) {
d.end()
})

test('misc - prints version', function (t) {
test('usage - prints version', function (t) {
var d = spawn(t, dat + ' -v')
d.stderr.match(function (output) {
var ver = output.indexOf(version) > -1
Expand All @@ -25,7 +25,7 @@ test('misc - prints version', function (t) {
d.end()
})

test('misc - also prints version', function (t) {
test('usage - also prints version', function (t) {
var d = spawn(t, dat + ' -v')
d.stderr.match(function (output) {
var ver = output.indexOf(version) > -1
Expand All @@ -34,3 +34,13 @@ test('misc - also prints version', function (t) {
})
d.end()
})

test('usage - help prints usage', function (t) {
var d = spawn(t, dat + ' help')
d.stderr.match(function (output) {
var usage = output.indexOf('Usage') > -1
if (!usage) return false
return true
})
d.end()
})

0 comments on commit 6b6fcbd

Please sign in to comment.