Skip to content

Commit

Permalink
Print minimal help #11
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Dec 11, 2021
1 parent 1da0c43 commit 79337b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ async function run(config) {
console.log(`STAC Node Validator v${version}\n`);
}

// Show minimal help output
if (args.help) {
console.log("For more information on using this command line tool, please visit");
console.log("https://github.com/stac-utils/stac-node-validator/blob/master/README.md#usage");

process.exit(0);
}

// Read config from file
if (typeof args.config === 'string') {
let configFile;
Expand Down
9 changes: 9 additions & 0 deletions tests/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ it('Should print version number', async () => {
expect(mockExit).toHaveBeenCalledWith(0);
});

it('Should print help', async () => {
await app({help: true});

expect(consoleLogSpy.mock.calls[0][0]).toContain(initString);
expect(consoleLogSpy.mock.calls[1][0]).toContain("For more information on using this command line tool, please visit");
expect(consoleLogSpy.mock.calls[2][0]).toContain("https://github.com/stac-utils/stac-node-validator/blob/master/README.md#usage");
expect(mockExit).toHaveBeenCalledWith(0);
});

describe('Running without parameters or configuration', () => {
it('Should return exit code 1', async () => {
await app();
Expand Down

0 comments on commit 79337b0

Please sign in to comment.