Skip to content

Commit

Permalink
Fix CLI options being limited
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Aug 15, 2021
1 parent 4ef8c0b commit a44fbbd
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.5.4
*2021-08-15*
- Fixed CLI options not being able to be negated.
- Fixed CLI option `--ignore` not allowing delimited paths.

## 1.5.3
*2021-08-14*
- Fixed shebang interpreter checking more than just the first line.
Expand Down
1 change: 1 addition & 0 deletions deprecate.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* languages.{data|markup|programming|prose}
* --ignore a;b;c
* --full
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linguist-js",
"version": "1.5.3",
"version": "1.5.4",
"description": "Analyse languages used in a folder. Powered by GitHub Linguist, although it doesn't need to be installed.",
"main": "dist/index.js",
"bin": {
Expand Down
24 changes: 15 additions & 9 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,31 @@ program

.requiredOption('-a|--analyze|--analyse [folder]', 'Analyse the language of all files found in a folder')
.option('-i|--ignore <files...>', `A list of file path globs to ignore`)
.option('-f|--files|--full', 'List every file parsed', false)
.option('-s|--summary', 'Show output in a human-readable format', false)
.option('-q|--quick', 'Skip checking of gitattributes/gitignore files (alias for -AIHS=false)', false)
.option('-V|--keepVendored', 'Prevent skipping over vendored/generated files', false)
.option('-A|--checkAttributes', 'Force the checking of gitattributes files (default: true unless --quick is set)')
.option('-I|--checkIgnored', 'Force the checking of gitignore files (default: true unless --quick is set)')
.option('-H|--checkHeuristics', 'Apply heuristics to ambiguous languages (default: true unless --quick is set)')
.option('-S|--checkShebang|--checkHashbang', 'Check shebang lines for explicit classification (default: true unless --quick is set)')
.option('-f|--files|--full [bool]', 'List every file parsed', false)
.option('-s|--summary [bool]', 'Show output in a human-readable format', false)
.option('-q|--quick [bool]', 'Skip checking of gitattributes/gitignore files (alias for -AIHS=false)', false)
.option('-V|--keepVendored [bool]', 'Prevent skipping over vendored/generated files', false)
.option('-B|--keepBinary [bool]', 'Prevent skipping over binary files', false)
.option('-A|--checkAttributes [bool]', 'Force the checking of gitattributes files (default: true unless --quick is set)', true)
.option('-I|--checkIgnored [bool]', 'Force the checking of gitignore files (default: true unless --quick is set)', true)
.option('-H|--checkHeuristics [bool]', 'Apply heuristics to ambiguous languages (default: true unless --quick is set)', true)
.option('-S|--checkShebang|--checkHashbang [bool]', 'Check shebang lines for explicit classification (default: true unless --quick is set)', true)

.helpOption(`-h|--help`, 'Display this help message')
.version(VERSION, '-v|--version', 'Display the installed version of linguist-js')

program.parse(process.argv);
const args = program.opts();
for (const arg in args) {
if (typeof args[arg] !== 'string') continue;
args[arg] = args[arg].replace(/^=/, '');
if (args[arg].match(/true$|false$/)) args[arg] = args[arg] === 'true';
}

if (args.analyze) {
(async () => {
const root = args.analyze === true ? '.' : args.analyze;
if (typeof args.ignore === 'string') args.ignore = args.ignore.split(/(?<!\\)[:;|]/);
if (args.ignore[0].match(/(?<!\\)[:;|]/)) args.ignore = args.ignore[0].split(/(?<!\\)[:;|]/);
const { count, languages, results } = await linguist(root, args);
if (args.summary) {
const { data, markup, programming, prose, total: { bytes: totalBytes } } = languages;
Expand Down

0 comments on commit a44fbbd

Please sign in to comment.