Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/cli/arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export function validate_arguments(args: ReturnType<typeof parse_arguments>): Cl
export function parse_arguments(args: string[]) {
let { values } = parseArgs({
args,
allowPositionals: true,
options: {
'coverage-dir': {
type: 'string',
Expand Down
5 changes: 5 additions & 0 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import { program } from './program.js'
import { read } from './file-reader.js'
import { print as pretty } from './reporters/pretty.js'
import { print as tap } from './reporters/tap.js'
import { help } from './help.js'

async function cli(cli_args: string[]) {
if (!cli_args || cli_args.length === 0 || cli_args.includes('--help') || cli_args.includes('-h')) {
return console.log(help())
}

let params = validate_arguments(parse_arguments(cli_args))
let coverage_data = await read(params['coverage-dir'])
let report = program(
Expand Down
37 changes: 37 additions & 0 deletions src/cli/help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { styleText } from 'node:util'

export function help() {
return `
${styleText(['bold'], 'USAGE')}
$ css-coverage --coverage-dir=<dir> --min-coverage=<number> [options]

${styleText('bold', 'OPTIONS')}
Required:
--coverage-dir Where your Coverage JSON files are
--min-coverage Minimum overall CSS coverage [0-1]

Optional:
--min-file-coverage Minimal coverage per file [0-1]

--show-uncovered Which files to show when not meeting
the --min-file-line-coverage threshold
• violations [default] ${styleText('dim', 'show under-threshold files')}
• all ${styleText('dim', 'show partially covered files')}
• none ${styleText('dim', 'do not show files')}

--reporter How to show the results
• pretty [default]
• tap
• json

${styleText('bold', 'EXAMPLES')}
${styleText('dim', '# analyze all .json files in ./coverage; require 80% overall coverage')}
$ css-coverage --coverage-dir=./coverage --min-coverage=0.8

${styleText('dim', '# Require 50% coverage per file')}
$ css-coverage --coverage-dir=./coverage --min-coverage=0.8 --min-file-coverage=0.5

${styleText('dim', 'Report JSON')}
$ css-coverage --coverage-dir=./coverage --min-coverage=0.8 --reporter=json
`.trim()
}