diff --git a/packages/cspell/bin.mjs b/packages/cspell/bin.mjs index 04e1de88303..a8a9062b8db 100755 --- a/packages/cspell/bin.mjs +++ b/packages/cspell/bin.mjs @@ -7,8 +7,8 @@ import * as app from './dist/esm/app.mjs'; app.run(program, process.argv).catch((e) => { if (!(e instanceof CommanderError) && !(e instanceof app.CheckFailed)) { - const msg = format(e) + '\n'; - process.stdout.write(msg); + const msg = e instanceof app.ApplicationError ? e.message : format(e); + process.stdout.write(msg + '\n'); // It is possible an explicit exit code was set, use it if it was. process.exitCode = process.exitCode || 1; } diff --git a/packages/cspell/src/app/__snapshots__/app.test.ts.snap b/packages/cspell/src/app/__snapshots__/app.test.ts.snap index e54ad415f78..dce72e677db 100644 --- a/packages/cspell/src/app/__snapshots__/app.test.ts.snap +++ b/packages/cspell/src/app/__snapshots__/app.test.ts.snap @@ -588,6 +588,149 @@ exports[`Validate cli > app 'link remove' 1`] = `""`; exports[`Validate cli > app 'link' 1`] = `""`; +exports[`Validate cli > app 'lint --help --issue-template' Expect Error: 'outputHelp' 1`] = ` +[ + "Usage: cspell lint [options] [globs...] [file:// ...] [stdin[://]]", + "", + "Patterns:", + " - [globs...] Glob Patterns", + " - [stdin] Read from "stdin" assume text file.", + " - [stdin://] Read from "stdin", use for file type and config.", + " - [file://] Check the file at ", + "", + "Examples:", + " cspell . Recursively check all files.", + " cspell lint . The same as "cspell ."", + " cspell "*.js" Check all .js files in the current directory", + " cspell "**/*.js" Check all .js files recursively", + " cspell "src/**/*.js" Only check .js under src", + " cspell "**/*.txt" "**/*.js" Check both .js and .txt files.", + " cspell "**/*.{txt,js,md}" Check .txt, .js, and .md files.", + " cat LICENSE | cspell stdin Check stdin", + " cspell stdin://docs/doc.md Check stdin as if it was "./docs/doc.md"", + "", + "Check spelling", + "", + "Options:", + " -c, --config Configuration file to use. By default cspell", + " looks for cspell.json in the current directory.", + " -v, --verbose Display more information about the files being", + " checked and the configuration.", + " --locale Set language locales. i.e. "en,fr" for English", + " and French, or "en-GB" for British English.", + " --language-id Force programming language for unknown", + " extensions. i.e. "php" or "scala"", + " --words-only Only output the words not found in the", + " dictionaries.", + " -u, --unique Only output the first instance of a word not", + " found in the dictionaries.", + " -e, --exclude Exclude files matching the glob pattern. This", + " option can be used multiple times to add", + " multiple globs.", + " --file-list Specify a list of files to be spell checked. The", + " list is filtered against the glob file patterns.", + " Note: the format is 1 file path per line.", + " --file [file...] Specify files to spell check. They are filtered", + " by the [globs...].", + " --no-issues Do not show the spelling errors.", + " --no-progress Turn off progress messages", + " --no-summary Turn off summary message in console.", + " -s, --silent Silent mode, suppress error messages.", + " --no-exit-code Do not return an exit code if issues are found.", + " --quiet Only show spelling issues or errors.", + " --fail-fast Exit after first file with an issue or error.", + " -r, --root Root directory, defaults to current directory.", + " --no-relative Issues are displayed with absolute path instead", + " of relative to the root.", + " --show-context Show the surrounding text around an issue.", + " --show-suggestions Show spelling suggestions.", + " --no-show-suggestions Do not show spelling suggestions or fixes.", + " --no-must-find-files Do not error if no files are found.", + " --cache Use cache to only check changed files.", + " --no-cache Do not use cache.", + " --cache-reset Reset the cache file.", + " --cache-strategy Strategy to use for detecting changed files.", + " (choices: "metadata", "content")", + " --cache-location Path to the cache file or directory. (default:", + " ".cspellcache")", + " --dot Include files and directories starting with \`.\`", + " (period) when matching globs.", + " --gitignore Ignore files matching glob patterns found in", + " .gitignore files.", + " --no-gitignore Do NOT use .gitignore files.", + " --gitignore-root Prevent searching for .gitignore files past", + " root.", + " --validate-directives Validate in-document CSpell directives.", + " --no-color Turn off color.", + " --color Force color.", + " --no-default-configuration Do not load the default configuration and", + " dictionaries.", + " --debug Output information useful for debugging", + " cspell.json files.", + " --reporter Specify one or more reporters to use.", + " --issue-template [template] Use a custom issue template. See --help", + " --issue-template for details.", + " -h, --help display help for command", + "", + "Issue Template:", + " Use "--issue-template" to set the template to use when reporting issues.", + "", + " The template is a string that can contain the following placeholders:", + " - $filename - the file name", + " - $col - the column number", + " - $row - the row number", + " - $text - the word that is misspelled", + " - $message - the issues message: "unknown word", "word is misspelled", etc.", + " - $messageColored - the issues message with color based upon the message type.", + " - $uri - the URI of the file", + " - $suggestions - suggestions for the misspelled word (if requested)", + " - $quickFix - possible quick fixes for the misspelled word.", + " - $contextFull - the full context of the misspelled word.", + " - $contextLeft - the context to the left of the misspelled word.", + " - $contextRight - the context to the right of the misspelled word.", + "", + " Color is supported using the following template pattern:", + " - \`{ }\` - where \`