Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(contact): add config to hide contact button #126

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Cloud Commander supports command line parameters:
| `--console` | enable console
| `--terminal` | enable terminal
| `--terminal-path` | set terminal path
| `--contact` | enable contact
| `--no-server` | do not start server
| `--no-auth` | disable authorization
| `--no-online` | load scripts from local server
Expand All @@ -96,6 +97,7 @@ Cloud Commander supports command line parameters:
| `--no-config-dialog` | disable config dialog
| `--no-console` | disable console
| `--no-terminal` | disable terminal
| `--no-contact` | disable contact
| `--no-name` | set empty tab name in web browser


Expand Down
67 changes: 35 additions & 32 deletions bin/cloudcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const env = require(DIR_SERVER + 'env');
const choose = (a, b) => {
if (!a && typeof a !== 'boolean')
return b;

return a;
};

Expand Down Expand Up @@ -41,6 +41,7 @@ const args = require('minimist')(argv.slice(2), {
'config-dialog',
'console',
'terminal',
'contact',
'one-panel-mode',
'html-dialogs',
'show-config',
Expand All @@ -61,7 +62,8 @@ const args = require('minimist')(argv.slice(2), {
progress : config('progress'),
console : config('console'),
terminal : choose(env.bool('terminal'), config('terminal')),

contact : config('contact'),

'terminal-path': env('terminal_path') || config('terminalPath'),
'config-dialog': choose(env.bool('config_dialog'), config('configDialog')),
'one-panel-mode': config('onePanelMode'),
Expand Down Expand Up @@ -92,18 +94,19 @@ else
function main() {
if (args.repl)
repl();

checkUpdate();

port(args.port);

config('name', args.name);
config('auth', args.auth);
config('online', args.online);
config('open', args.open);
config('username', args.username);
config('progress', args.progress);
config('console', args.console);
config('contact', args.contact);
config('terminal', args.terminal);
config('terminalPath', args['terminal-path']);
config('editor', args.editor);
Expand All @@ -112,29 +115,29 @@ function main() {
config('htmlDialogs', args['html-dialogs']);
config('onePanelMode', args['one-panel-mode']);
config('configDialog', args['config-dialog']);

readConfig(args.config);

const options = {
root: args.root || '/', /* --no-root */
editor: args.editor,
packer: args.packer,
prefix: args.prefix
};

const password = env('password') || args.password;

if (password)
config('password', getPassword(password));

validateRoot(options.root);

if (args['show-config'])
showConfig();

if (!args.save)
return start(options);

config.save(() => {
start(options);
});
Expand All @@ -147,7 +150,7 @@ function validateRoot(root) {

function getPassword(password) {
const criton = require('criton');

return criton(password, config('algo'));
}

Expand All @@ -157,48 +160,48 @@ function version() {

function start(config) {
const SERVER = DIR_SERVER + 'server';

if (args.server)
require(SERVER)(config);
}

function port(arg) {
const number = parseInt(arg, 10);

if (!isNaN(number))
return config('port', number);

exit('cloudcmd --port: should be a number');
}

function showConfig() {
const show = require('../server/show-config');
const data = show(config('*'));

console.log(data);
}

function readConfig(name) {
if (!name)
return;

const fs = require('fs');
const tryCatch = require('try-catch');
const jju = require('jju');

const readjsonSync = (name) => jju.parse(fs.readFileSync(name, 'utf8'), {
mode: 'json'
});

let data;

const error = tryCatch(() => {
data = readjsonSync(name);
});

if (error)
return exit(error.message);

Object.keys(data).forEach((item) => {
config(item, data[item]);
});
Expand All @@ -208,14 +211,14 @@ function help() {
const bin = require('../json/help');
const usage = 'Usage: cloudcmd [options]';
const url = Info.homepage;

console.log(usage);
console.log('Options:');

Object.keys(bin).forEach((name) => {
console.log(' %s %s', name, bin[name]);
});

console.log('\nGeneral help using Cloud Commander: <%s>', url);
}

Expand All @@ -227,27 +230,27 @@ function repl() {
function checkUpdate() {
const load = require('package-json');
const noop = () => {};

load(Info.name, 'latest')
.then(showUpdateInfo)
.catch(noop);
}

function showUpdateInfo(data) {
const version = data.version;

if (version !== Info.version) {
const chalk = require('chalk');
const rendy = require('rendy');

const latest = rendy('update available: {{ latest }}', {
latest: chalk.green.bold('v' + version),
});

const current = chalk.dim(rendy('(current: v{{ current }})', {
current: Info.version
}));

console.log('%s %s', latest, current);
}
}
Expand Down
2 changes: 1 addition & 1 deletion json/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"htmlDialogs": true,
"configDialog": true,
"onePanelMode": false,
"configDialog": true,
"contact": true,
"console": true,
"terminal": false,
"terminalPath": "",
Expand Down
2 changes: 2 additions & 0 deletions json/help.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"--console ": "enable console",
"--terminal ": "enable terminal",
"--terminal-path ": "set terminal path",
"--contact ": "enable contact",
"--open ": "open web browser when server started",
"--name ": "set tab name in web browser",
"--no-server ": "do not start server",
Expand All @@ -32,5 +33,6 @@
"--no-config-dialog ": "disable config dialog",
"--no-console ": "disable console",
"--no-terminal ": "disable terminal",
"--no-contact ": "disable contact",
"--no-name ": "set default tab name in web browser"
}
2 changes: 2 additions & 0 deletions man/cloudcmd.1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ programs in browser from any computer, mobile or tablet device.
--console enable console
--terminal enable terminal
--terminal-path set terminal path
--contact enable contact
--open open web browser when server started
--name set tab name in web browser
--no-auth disable authorization
Expand All @@ -55,6 +56,7 @@ programs in browser from any computer, mobile or tablet device.
--no-config-dialog disable config dialog
--no-console disable console
--no-terminal disable terminal
--no-contact disable contact
--no-name set default tab name in web browser

.SH RESOURCES AND DOCUMENTATION
Expand Down