X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=cli%2Fsurfer.js;h=bd574f54b6f5e2d41023212066a7bfc501bce864;hb=HEAD;hp=15a88b39d602ca0f0446577050a7e7cc0bf54a0e;hpb=32fbb54d41789f7c673d79509b354abcacca2a62;p=perso%2FImmae%2FProjets%2FNodejs%2FSurfer.git diff --git a/cli/surfer.js b/cli/surfer.js index 15a88b3..bd574f5 100755 --- a/cli/surfer.js +++ b/cli/surfer.js @@ -5,26 +5,46 @@ 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...]') - .option('-d --destination ', 'Destination folder. This is prepended to the relative path') - .description('Put a file') - .action(actions.put); - -program.command('get') - .description('Get a file or directory') +program.command('logout') + .description('Logout from server') + .action(actions.logout); + +program.command('put ') + .option('-a --all', 'Also include hidden files and folders.', false) + .description('Puts a list of files or dirs to the destination. The last argument is destination dir') + .action(actions.put) + .on('--help', function() { + console.log(); + console.log(' Examples:'); + console.log(); + console.log(' $ surfer put file.txt / # puts to /file.txt'); + console.log(' $ surfer put file.txt /data # puts to /data/file.txt'); + console.log(' $ surfer put dir /data # puts dir/* as /data/dir/*'); + console.log(' $ surfer put dir/. / # puts dir/* as /app/data/*'); + console.log(' $ surfer put dir1 dir2 file1 / # puts as /dir1/* /dir2/* and /file'); + console.log(); + }); + +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 +52,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); + // } }