Skip to content

Commit

Permalink
fix: CLI usage simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Aug 24, 2016
1 parent d3219f0 commit 3ea82dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions cli/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ module.exports = (args) => {
throw new Error(`unknown command "${command}"`);
}

if (args.logs) {
if (args.verbose) {
require('debug').enable('broker*');
}

require(`${__dirname}/../lib/${command}`)(args);
args.client = command === 'client';

require(`${__dirname}/../lib/index`).main(args);
};
2 changes: 1 addition & 1 deletion cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ clite({
_: 'cli/exec',
},
options: ['env', 'port'],
alias: { V: 'verbose' },
alias: { V: 'verbose', 'v': 'version' },
booleans: [
'verbose',
],
Expand Down
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ const app = module.exports = {
main: main,
};

function main({ port } = {}) {
function main({ port, client } = {}) {
// note: the config is loaded in the main function to allow us to mock in tests
const config = require('./config');
const client = !!config.brokerUrl;
if (client === undefined) {
client = !!config.brokerUrl;
}

const method = client ? 'client' : 'server';
process.env.BROKER_TYPE = method;

Expand Down

0 comments on commit 3ea82dd

Please sign in to comment.