Skip to content

Commit 7c36f29

Browse files
committed
Create debug mode option
1 parent 7501f0b commit 7c36f29

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/_options.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ module.exports = {
5353
{
5454
short: '-o',
5555
name: 'override',
56-
description: 'Override the release notes if exist.'
56+
description: 'Override the release notes if exist'
57+
},
58+
{
59+
short: '-B',
60+
name: 'debug',
61+
description: 'Run the command in debugging mode'
5762
},
5863
{
5964
short: '-t',

lib/src/Gren.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const defaults = {
1414
prerelease: false,
1515
generate: false,
1616
override: false,
17+
debug: false,
1718
ignoreLabels: false,
1819
ignoreIssuesWith: false,
1920
ignoreCommitsWith: false,
@@ -53,6 +54,10 @@ class Gren {
5354
throw chalk.red('You must provide the TOKEN');
5455
}
5556

57+
if (this.options.debug) {
58+
this._outputOptions(this.options);
59+
}
60+
5661
const githubApi = new Github({
5762
token
5863
}, apiUrl);
@@ -929,6 +934,20 @@ class Gren {
929934
});
930935
});
931936
}
937+
938+
/**
939+
* Output the options in the terminal in a formatted way
940+
*
941+
* @param {Object} options
942+
*/
943+
_outputOptions(options) {
944+
const camelcaseToSpaces = value => value.replace(/([A-Z])/g, ' $1').toLowerCase().replace(/\w/, a => a.toUpperCase());
945+
const outputs = Object.entries(options)
946+
.filter(option => option !== 'debug')
947+
.map(([key, value]) => `${chalk.yellow(camelcaseToSpaces(key))}: ${value.toString() || 'empty'}`);
948+
949+
process.stdout.write('\n' + chalk.blue('Options: \n') + outputs.join('\n') + '\n');
950+
}
932951
}
933952

934953
export default Gren;

0 commit comments

Comments
 (0)