-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcli.coffee
executable file
·34 lines (28 loc) · 1.09 KB
/
cli.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
commander = require 'commander'
chalk = require 'chalk'
crawler = require './crawler'
crawlerUrl = null
validTags = ['wcag2a', 'wcag2aa', 'section508', 'best-practice']
collectFilters = (filterString, filtersList) ->
filtersList.push filterString
return filtersList
parseTags = (tagStr) ->
return tagStr.split(',').map (str) -> str.trim()
commander
.usage '[options] <url>'
.description 'Crawls a website and reports accessibility issues for each page.'
.option '-c, --csv <filepath>', 'path to CSV output file'
.option '-i, --include [string]', 'include only URLs containing this string', collectFilters, []
.option '-e, --exclude [string]', 'exclude any URLs containing this string', collectFilters, []
.option '-t, --tags <string>', "comma-separated list of rule tags (#{ validTags.join(',') })", parseTags, 'wcag2aa'
.option '-x, --xpaths', 'show xpaths in console results'
.parse process.argv
unless commander.args[0]
commander.help()
crawler
url: commander.args[0]
csv: commander.csv,
include: commander.include
exclude: commander.exclude
tags: commander.tags
xpaths: commander.xpaths