Skip to content

Commit 79337b0

Browse files
committed
Print minimal help #11
1 parent 1da0c43 commit 79337b0

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ async function run(config) {
3838
console.log(`STAC Node Validator v${version}\n`);
3939
}
4040

41+
// Show minimal help output
42+
if (args.help) {
43+
console.log("For more information on using this command line tool, please visit");
44+
console.log("https://github.com/stac-utils/stac-node-validator/blob/master/README.md#usage");
45+
46+
process.exit(0);
47+
}
48+
4149
// Read config from file
4250
if (typeof args.config === 'string') {
4351
let configFile;

tests/cli.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ it('Should print version number', async () => {
3333
expect(mockExit).toHaveBeenCalledWith(0);
3434
});
3535

36+
it('Should print help', async () => {
37+
await app({help: true});
38+
39+
expect(consoleLogSpy.mock.calls[0][0]).toContain(initString);
40+
expect(consoleLogSpy.mock.calls[1][0]).toContain("For more information on using this command line tool, please visit");
41+
expect(consoleLogSpy.mock.calls[2][0]).toContain("https://github.com/stac-utils/stac-node-validator/blob/master/README.md#usage");
42+
expect(mockExit).toHaveBeenCalledWith(0);
43+
});
44+
3645
describe('Running without parameters or configuration', () => {
3746
it('Should return exit code 1', async () => {
3847
await app();

0 commit comments

Comments
 (0)