From d62049cd5915681a1fe94e8901b442bf5cc645d0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Aug 2015 07:39:24 -0400 Subject: [PATCH] feature(cloudcmd) add --prefix --- HELP.md | 2 ++ bin/cloudcmd.js | 7 +++++-- json/bin.json | 1 + json/config.json | 1 + lib/cloudcmd.js | 11 +++++++++-- man/cloudcmd.1 | 1 + 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/HELP.md b/HELP.md index 95db95cd..f824aec4 100644 --- a/HELP.md +++ b/HELP.md @@ -67,6 +67,7 @@ Cloud Commander supports command line parameters: | `-c, --config` | configuration file path | `--editor` | set editor: "dword" or "edward" | `--root` | set root directory +| `--prefix` | set url prefix | `--port` | set port number | `--no-auth` | disable authorization | `--no-server` | do not start server @@ -215,6 +216,7 @@ Here is description of options: "port" : 8000, /* http port */ "ip" : null, /* ip or null(default) */ "root" : "/" /* root directory */ + "prefix" : "", /* url prefix */ "progress" : true /* show progress of file operations */ } ``` diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index 12150c2f..77577bd6 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -21,7 +21,8 @@ 'username', 'config', 'editor', - 'root' + 'root', + 'prefix' ], boolean: [ 'auth', @@ -42,6 +43,7 @@ editor : config('editor') || 'edward', username : config('username'), root : config('root') || '/', + prefix : config('prefix') || '', progress : config('progress') || config('progressOfCopying'), }, alias: { @@ -83,7 +85,8 @@ options = { root: args.root, - editor: args.editor + editor: args.editor, + prefix: args.prefix }; if (args.password) diff --git a/json/bin.json b/json/bin.json index 081cfbef..b21032d8 100644 --- a/json/bin.json +++ b/json/bin.json @@ -9,6 +9,7 @@ "-c, --config ": "configuration file path", "--editor ": "set editor: \"dword\" or \"edward\"", "--root ": "set root directory", + "--prefix ": "set url prefix", "--port ": "set port number", "--no-auth ": "disable authorization", "--no-server ": "do not start server", diff --git a/json/config.json b/json/config.json index 6dfdd2a5..19ee0e77 100644 --- a/json/config.json +++ b/json/config.json @@ -17,5 +17,6 @@ "port": 8000, "ip": null, "root": "/", + "prefix": "", "progress": true } diff --git a/lib/cloudcmd.js b/lib/cloudcmd.js index 1bb9b29e..6f0f03dc 100644 --- a/lib/cloudcmd.js +++ b/lib/cloudcmd.js @@ -50,9 +50,9 @@ } module.exports = function(params) { - var p = params || {}, + var prefix, + p = params || {}, options = p.config || {}, - prefix = p.prefix, keys = Object.keys(options); keys.forEach(function(name) { @@ -67,6 +67,13 @@ break; case 'password': value = createPass(config('algo'), value); + break; + case 'prefix': + if (!~value.indexOf('/')) + value = '/' + value; + + prefix = value; + break; } diff --git a/man/cloudcmd.1 b/man/cloudcmd.1 index a800cdbc..86c39e88 100644 --- a/man/cloudcmd.1 +++ b/man/cloudcmd.1 @@ -32,6 +32,7 @@ programs in browser from any computer, mobile or tablet device. -c, --config configuration file path --editor set editor: "dword" or "edward" --root set root directory + --prefix set url prefix --port set port number --no-auth disable authorization --no-server do not start server