diff --git a/bin/cli.js b/bin/cli.js index 1ad3538..0952538 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -8,13 +8,12 @@ process.title = 'dat-next' var config = { defaults: [ - { name: 'dir', default: process.cwd() }, + { name: 'dir', default: process.cwd(), help: 'set the directory for Dat' }, { name: 'logspeed', default: 200 }, - { name: 'port', default: 3282 }, - { name: 'utp', default: true, boolean: true }, - { name: 'debug', default: process.env.DEBUG }, + { name: 'port', default: 3282, help: 'port to use for connections' }, + { name: 'utp', default: true, boolean: true, help: 'use utp for discovery' }, + { name: 'debug', default: process.env.DEBUG }, // TODO: does not work right now { name: 'quiet', default: false, boolean: true }, - { name: 'verbose', default: false, boolean: true, abbr: 'v' }, { name: 'server', default: 'https://dat.land/api/v1' } ], root: { @@ -40,12 +39,15 @@ 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') + ], + usage: { + command: usage, + option: { name: 'help', - command: usage + abbr: 'h' } - ], + }, aliases: { 'init': 'create' } diff --git a/lib/commands/clone.js b/lib/commands/clone.js index 7cf4634..cb823ff 100644 --- a/lib/commands/clone.js +++ b/lib/commands/clone.js @@ -8,11 +8,23 @@ var debug = require('debug')('dat') module.exports = { name: 'clone', command: clone, + help: [ + 'Clone a remote Dat archive', + '', + 'Usage: dat clone [download-folder]' + ].join('\n'), options: [ { name: 'temp', boolean: true, - default: false + default: false, + help: 'use an in-memory database for metadata' + }, + { + name: 'upload', + boolean: true, + default: false, + help: 'upload data to other peers while cloning' } ] } diff --git a/lib/commands/create.js b/lib/commands/create.js index d223f8d..d9e79cb 100644 --- a/lib/commands/create.js +++ b/lib/commands/create.js @@ -8,11 +8,17 @@ var debug = require('debug')('dat') module.exports = { name: 'create', command: create, + help: [ + 'Create a local Dat archive to share', + '', + 'Usage: dat create [directory]' + ].join('\n'), options: [ { name: 'import', boolean: true, - default: true + default: true, + help: 'Import files in the given directory' }, { name: 'ignoreHidden', diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index 38eb10c..ddbe81e 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -2,6 +2,13 @@ var doctor = require('dat-doctor') module.exports = { name: 'doctor', + help: [ + 'Call the Doctor! Runs two tests:', + ' 1. Check if you can connect to a peer on a public server.', + ' 2. Gives you a link to test direct peer connections.', + '', + 'Usage: dat doctor []' + ].join('\n'), options: [], command: function (opts) { opts.id = opts._[0] diff --git a/lib/commands/pull.js b/lib/commands/pull.js index aa4ead6..5a00168 100644 --- a/lib/commands/pull.js +++ b/lib/commands/pull.js @@ -5,7 +5,19 @@ var debug = require('debug')('dat') module.exports = { name: 'pull', - options: [], + help: [ + 'Pull updates from a cloned Dat archive', + '', + 'Usage: dat pull' + ].join('\n'), + options: [ + { + name: 'upload', + boolean: true, + default: false, + help: 'upload data to other peers while pulling' + } + ], command: function (opts) { // Force these options for pull command opts.resume = true diff --git a/lib/commands/snapshot.js b/lib/commands/snapshot.js index ebe66d7..02b21d6 100644 --- a/lib/commands/snapshot.js +++ b/lib/commands/snapshot.js @@ -3,6 +3,11 @@ var debug = require('debug')('dat') module.exports = { name: 'snapshot', + help: [ + 'Create a snapshot Dat archive', + '', + 'Usage: dat snapshot' + ].join('\n'), options: [], command: function snapshot (opts) { // Force these options for snapshot command diff --git a/lib/commands/sync.js b/lib/commands/sync.js index f3cc857..6094e5f 100644 --- a/lib/commands/sync.js +++ b/lib/commands/sync.js @@ -6,11 +6,18 @@ var debug = require('debug')('dat') module.exports = { name: 'sync', + help: [ + 'Sync a Dat archive with the network', + 'Watch and import file changes (if you created the archive)', + '', + 'Usage: dat sync' + ].join('\n'), options: [ { name: 'import', boolean: true, - default: true + default: true, + help: 'Import files from the directory to the database.' }, { name: 'ignoreHidden', @@ -21,7 +28,8 @@ module.exports = { { name: 'watch', boolean: true, - default: true + default: true, + help: 'Watch for changes and import updated files.' } ], command: function (opts) { diff --git a/lib/usage.js b/lib/usage.js index 6c3e308..51b57f9 100644 --- a/lib/usage.js +++ b/lib/usage.js @@ -1,32 +1,30 @@ -module.exports = function (opts) { +module.exports = function (opts, help, usage) { if (opts.version) { var pkg = require('../package.json') console.error(pkg.version) process.exit(1) } console.error('Usage: dat [options]') - console.error(' dat create create a local archive') - console.error(' dat snapshot create a local snapshot archive') - console.error(' dat clone clone a remote archive') console.error('') - console.error(' dat sync sync files with the network') - console.error(' dat pull update from remote archive & exit') + console.error('Sharing Files:') + console.error(' dat create [] create a local archive') + console.error(' dat snapshot create a local snapshot archive') + console.error(' dat sync watch for changes & sync files with the network') console.error('') - console.error(' --dir= set directory') - console.error(' --no-import do not import files (create, sync)') - console.error(' --quiet only print out the dat link') - console.error(' --port=3282 set the port for discovery') - console.error(' --no-utp do not use utp for network connections') + console.error('Downloading Files:') + console.error(' dat clone [] clone a remote archive') + console.error(' dat pull update from remote archive & exit') + console.error(' dat sync sync files with the network') console.error('') - console.error(' dat register register for an account') - console.error(' dat login login to an account') - console.error(' dat logout logout from the server') - console.error(' dat whoami get login information') - console.error(' dat publish publish dataset to registry') - console.error('') - console.error(' dat --version, -v get your dat version') - console.error(' dat help print this usage guide') - console.error(' dat doctor run the dat network doctor') + console.error('Help & Troubleshooting:') + console.error(' dat doctor run the dat network doctor') + console.error(' dat [] --help, -h print help for a command') + console.error(' dat --version, -v print your dat version') console.error('') + if (usage) { + console.error('General Options:') + console.error(usage) + } + console.error('Have fun using Dat! Learn more at docs.datproject.org') process.exit(1) } diff --git a/package.json b/package.json index ca3589d..781358c 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "prompt": "^1.0.0", "rimraf": "^2.5.4", "status-logger": "^3.0.0", - "subcommand": "^2.0.4", + "subcommand": "^2.1.0", "township-client": "^1.3.1", "xtend": "^4.0.1" },