X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=cli%2Fsurfer.js;h=33b4db6c23b1fe5af033112fad8ebf671f8aeb05;hb=ec4c48f288f465d66accb4fe4b2e872feff38715;hp=b311658ca275d7010ccc60a41a5e6946a1a3db1c;hpb=c9d33e20bf7d74b0d8a7eb1e1c89e8a845098460;p=perso%2FImmae%2FProjets%2FNodejs%2FSurfer.git diff --git a/cli/surfer.js b/cli/surfer.js index b311658..33b4db6 100755 --- a/cli/surfer.js +++ b/cli/surfer.js @@ -5,26 +5,35 @@ var program = require('commander'), actions = require('./actions'); -// Allow self signed certs! -process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; +program.version(require('../package.json').version); -program.version('0.1.0'); +// Those override the login settings if provided +program.option('-s, --server ', 'Server URL (optional)'); +program.option('-t, --token ', 'Server Access Token (optional)'); program.command('login ') .description('Login to server') + .option('--username [username]', 'Username (optional)') + .option('--password [password]', 'Password (optional)') .action(actions.login); -program.command('put [files...]') +program.command('logout') + .description('Logout from server') + .action(actions.logout); + +program.command('put [files...]') .option('-a --all', 'Also include hidden files and folders.', false) .description('Put a file, last argument is destination if provided') .action(actions.put); -program.command('get [file]') - .description('Get a file or directory') +program.command('get [file|dir]') + .description('Get a file or directory listing') .action(actions.get); -program.command('del') - .description('Delete a file') +program.command('del ') + .option('-r --recursive', 'Recursive delete directories.', false) + .option('-d --dry-run', 'Only list files to delete.', false) + .description('Delete a file or directory') .action(actions.del); program.parse(process.argv); @@ -32,9 +41,9 @@ program.parse(process.argv); if (!process.argv.slice(2).length) { program.outputHelp(); } else { // https://github.com/tj/commander.js/issues/338 - var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; }); - if (!knownCommand) { - console.error('Unknown command: ' + process.argv[2]); - process.exit(1); - } + // var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2]; }); + // if (!knownCommand) { + // console.error('Unknown command: ' + process.argv[2]); + // process.exit(1); + // } }