Skip to content

Commit 5e1fce6

Browse files
authored
fix: version flag when running with no args (#513)
1 parent d0a5d3a commit 5e1fce6

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Scan a given SBOM for EOL data
197197
```
198198
USAGE
199199
$ hd scan eol [--json] [-f <value> | -d <value>] [-s] [-o <value>] [--saveSbom] [--sbomOutput <value>]
200-
[--saveTrimmedSbom] [--hideReportUrl] [--automated] [--version]
200+
[--saveTrimmedSbom] [--hideReportUrl] [--automated]
201201
202202
FLAGS
203203
-d, --dir=<value> [default: <current directory>] The directory to scan in order to create a cyclonedx SBOM
@@ -210,7 +210,6 @@ FLAGS
210210
--saveSbom Save the generated SBOM as herodevs.sbom.json in the scanned directory
211211
--saveTrimmedSbom Save the trimmed SBOM as herodevs.sbom-trimmed.json in the scanned directory
212212
--sbomOutput=<value> Save the generated SBOM to a custom path (defaults to herodevs.sbom.json when not provided)
213-
--version Show CLI version.
214213
215214
GLOBAL FLAGS
216215
--json Format output as json.

bin/main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ import { parseArgs } from 'node:util';
22
import { execute } from '@oclif/core';
33

44
async function main(isProduction = false) {
5-
const { positionals } = parseArgs({
5+
const { positionals, values } = parseArgs({
66
allowPositionals: true,
77
strict: false, // Don't validate flags
8+
options: {
9+
version: { type: 'boolean', short: 'v' },
10+
},
811
});
912

10-
// If no arguments at all, default to help
11-
if (positionals.length === 0) {
13+
// If no arguments at all, default to help (but not if --version/-v was passed)
14+
if (positionals.length === 0 && !values.version) {
1215
process.argv.splice(2, 0, 'help');
1316
}
1417

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"license": "MIT",
9898
"main": "dist/index.js",
9999
"oclif": {
100+
"additionalVersionFlags": ["-v"],
100101
"bin": "hd",
101102
"dirname": "hd",
102103
"commands": "./dist/commands",

0 commit comments

Comments
 (0)