]> git.immae.eu Git - perso/Immae/Projets/Nodejs/Surfer.git/blobdiff - cli/surfer.js
Add --server and --token options to cli tool
[perso/Immae/Projets/Nodejs/Surfer.git] / cli / surfer.js
index ef3ed9119eaef8b74d2c3b747b31bd58c8ced4cc..33b4db6c23b1fe5af033112fad8ebf671f8aeb05 100755 (executable)
@@ -7,20 +7,26 @@ var program = require('commander'),
 
 program.version(require('../package.json').version);
 
+// Those override the login settings if provided
+program.option('-s, --server <url>', 'Server URL (optional)');
+program.option('-t, --token <access token>', 'Server Access Token (optional)');
+
 program.command('login <url>')
     .description('Login to server')
+    .option('--username [username]', 'Username (optional)')
+    .option('--password [password]', 'Password (optional)')
     .action(actions.login);
 
 program.command('logout')
     .description('Logout from server')
     .action(actions.logout);
 
-program.command('put <file> [files...]')
+program.command('put <file|dir> [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]')
+program.command('get [file|dir]')
     .description('Get a file or directory listing')
     .action(actions.get);
 
@@ -35,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);
+    // }
 }