diff --git a/HELP.md b/HELP.md index bd2660a6..49663c1b 100644 --- a/HELP.md +++ b/HELP.md @@ -78,9 +78,11 @@ Cloud Commander supports command line parameters: | `--minify` | enable minification | `--progress` | show progress of file operations | `--html-dialogs` | show html dialogs +| `--open` | open web browser when server started | `--no-server` | do not start server | `--no-auth` | disable authorization | `--no-online` | load scripts from local server +| `--no-open` | do not open web browser when server started | `--no-minify` | disable minification | `--no-progress` | do not show progress of file operations | `--no-html-dialogs` | do not use html dialogs @@ -223,6 +225,7 @@ Here is description of options: "dirStorage" : true, /* store directory listing to localStorage */ "minify" : false, /* minification of js,css,html and img */ "online" : true, /* load js files from cdn or local path */ + "open" : false /* open web browser when server started */ "cache" : true, /* add cache-control */ "showKeysPanel" : true, /* show classic panel with buttons of keys */ "port" : 8000, /* http port */ @@ -585,3 +588,4 @@ Special Thanks - config template and style; - change order of directories and files; - add ability do not hide path and header when files are scrolling; + diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index a80ffcb1..be2eb899 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -30,6 +30,7 @@ 'save', 'server', 'online', + 'open', 'minify', 'progress', 'progress-of-copying', @@ -41,6 +42,7 @@ port : config('port'), minify : config('minify'), online : config('online'), + open : config('open'), editor : config('editor') || 'edward', username : config('username'), root : config('root') || '/', @@ -78,6 +80,7 @@ config('auth', args.auth); config('online', args.online); + config('open', args.open); config('minify', args.minify); config('username', args.username); config('progress', args.progress); diff --git a/json/bin.json b/json/bin.json index 046e50eb..2035dafd 100644 --- a/json/bin.json +++ b/json/bin.json @@ -14,9 +14,11 @@ "--minify ": "enable minification", "--progress ": "show progress of file operations", "--html-dialogs ": "use html dialogs", + "--open ": "open web browser when server started", "--no-server ": "do not start server", "--no-auth ": "disable authorization", "--no-online ": "load scripts from local server", + "--no-open ": "do not open web browser when server started", "--no-minify ": "disable minification", "--no-progress ": "do not show progress of file operations", "--no-html-dialogs ": "do not use html dialogs" diff --git a/json/config.json b/json/config.json index 63d3a589..80f1a267 100644 --- a/json/config.json +++ b/json/config.json @@ -12,6 +12,7 @@ "dirStorage": false, "minify": false, "online": true, + "open": false, "cache": true, "showKeysPanel": true, "port": 8000, diff --git a/lib/server.js b/lib/server.js index efe9060b..aedf9c64 100644 --- a/lib/server.js +++ b/lib/server.js @@ -5,6 +5,7 @@ DIR_SERVER = DIR_LIB + 'server/', http = require('http'), + opn = require('opn'), cloudcmd = require(DIR_LIB + 'cloudcmd'), exit = require(DIR_SERVER + 'exit'), @@ -61,7 +62,8 @@ }; getPort(function(error, port) { - var url = config('ip') || 'localhost' + prefix(); + var host = config('ip') || 'localhost'; + var url = 'http://' + host + ':' + port + prefix() + '/'; if (error) return onError(error); @@ -69,7 +71,10 @@ server.listen(port, ip); server.on('error', onError); - console.log('url: http://%s:%d', url, port); + console.log('url:', url); + + if (config('open')) + opn(url); }); }; })(); diff --git a/man/cloudcmd.1 b/man/cloudcmd.1 index f16ccdd2..f16743b7 100644 --- a/man/cloudcmd.1 +++ b/man/cloudcmd.1 @@ -37,9 +37,11 @@ programs in browser from any computer, mobile or tablet device. --minify enable minification --progress show progress of file operations --html-dialogs use html dialogs + --open open web browser when server started --no-auth disable authorization --no-server do not start server --no-online load scripts from local server + --no-open do not open web browser when server started --no-minify disable minification --no-progress do not show progress of file operations --no-html-dialogs do not use html dialogs @@ -47,3 +49,4 @@ programs in browser from any computer, mobile or tablet device. .SH RESOURCES AND DOCUMENTATION General help using Cloud Commander: + diff --git a/package.json b/package.json index 541c3ab7..2afd445f 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "minify": "~2.0.0", "minimist": "~1.2.0", "mollify": "~1.0.0", + "opn": "~4.0.1", "os-homedir": "~1.0.0", "package-json": "~2.3.0", "pipe-io": "~1.2.0",