UNPKG

1.77 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3var path = require("path"),
4 nomnom = require("nomnom"),
5 replace = require("../replace");
6
7var options = nomnom.opts({
8 regex: {
9 position: 0,
10 help: "JavaScript regex for searching file e.g. '\\d+'",
11 required: true
12 },
13 path: {
14 position: 1,
15 help: "File or directory to search (default is '.')",
16 list: true,
17 default: ["."]
18 },
19 recursive: {
20 string: '-r, --recursive',
21 help: "Recursively search directories"
22 },
23 ignoreCase: {
24 string: '-i, --ignore-case',
25 help: "Ignore case when searching"
26 },
27 include: {
28 string: '--include=PATHS',
29 help: "Only search in these files, e.g. '*.js,*.foo'"
30 },
31 exclude: {
32 string: '--exclude=PATHS',
33 help: "Don't search in these files, e.g. 'test*,*.min.js'"
34 },
35 excludeList: {
36 string: '--exclude-list=FILE',
37 help: "File containing a new-line separated list of files to ignore",
38 default: path.join(__dirname, "..", "defaultignore"),
39 hidden: true
40 },
41 maxLines: {
42 string: '-n NUMLINES',
43 help: 'limit the number of lines to preview'
44 },
45 count: {
46 string: '-c, --count',
47 help: 'display count of occurances in each file'
48 },
49 quiet: {
50 string: '-q, --quiet',
51 help: "Just print the names of the files matches occured in (faster)"
52 },
53 color: {
54 string: '--color=COLOR',
55 help: "highlight color, e.g. 'green', 'blue', 'bold'",
56 default: 'cyan'
57 },
58 async: {
59 string: '-a, --async',
60 help: "asynchronously read/write files in directory (faster)"
61 }
62 })
63 .scriptName("search")
64 .parseArgs();
65
66replace(options);