Skip to content

Commit 31df2dd

Browse files
committed
bin: add a flag to list the subsystems
This commit adds the flag --list-subsystems to list all the subsystems that are available for use. fixes nodejs#66
1 parent 5740678 commit 31df2dd

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

bin/cmd.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ const formatTap = require('../lib/format-tap')
1414
const Validator = require('../lib')
1515
const Tap = require('../lib/tap')
1616
const utils = require('../lib/utils')
17+
const subsystem = require('../lib/rules/subsystem')
1718
const knownOpts = { help: Boolean
1819
, version: Boolean
1920
, 'validate-metadata': Boolean
2021
, tap: Boolean
2122
, out: path
2223
, list: Boolean
24+
, 'list-subsystems': Boolean
2325
}
2426
const shortHand = { h: ['--help']
2527
, v: ['--version']
2628
, V: ['--validate-metadata']
2729
, t: ['--tap']
2830
, o: ['--out']
2931
, l: ['--list']
32+
, ls: ['--list-subsystems']
3033
}
3134

3235
const parsed = nopt(knownOpts, shortHand)
@@ -84,6 +87,11 @@ function loadPatch(uri, cb) {
8487

8588
const v = new Validator(parsed)
8689

90+
if (parsed['list-subsystems']) {
91+
utils.describeSubsystem(subsystem.defaults.subsystems)
92+
return
93+
}
94+
8795
if (parsed.list) {
8896
const ruleNames = Array.from(v.rules.keys())
8997
const max = ruleNames.reduce((m, item) => {

bin/usage.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ core-validate-commit - Validate the commit message for a particular commit in no
88
-V, --validate-metadata validate PR-URL and reviewers (on by default)
99
-t, --tap output in tap format
1010
-l, --list list rules and their descriptions
11+
-ls --list-subsystems list the available subsystems
1112

1213
examples:
1314
Validate a single sha:

lib/utils.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,16 @@ exports.describeRule = function describeRule(rule, max = 20) {
4545
console.log(' %s %s', chalk.red(title), chalk.dim(desc))
4646
}
4747
}
48+
49+
exports.describeSubsystem = function describeSubsystem(subsystems, max = 20) {
50+
if (subsystems) {
51+
for (let sub = 0; sub < subsystems.length; sub++) {
52+
console.log('%s %s %s',
53+
chalk.green(exports.leftPad(subsystems[sub] || '', max)),
54+
chalk.green(exports.leftPad(subsystems[sub+1] || '', max)),
55+
chalk.green(exports.leftPad(subsystems[sub+2] || '', max))
56+
)
57+
sub += 2
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)