find-cli 1.6.3 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/bin/abbreviations.js +11 -1
- package/bin/action/find.js +8 -5
- package/bin/action/help.js +2 -0
- package/bin/configuration/version_1_4.js +1 -24
- package/bin/configuration/version_1_7.js +44 -0
- package/bin/configuration.js +30 -4
- package/bin/constants.js +2 -0
- package/bin/defaults.js +2 -0
- package/bin/descriptions.js +4 -2
- package/bin/main.js +4 -4
- package/bin/messages.js +4 -2
- package/bin/occurrence.js +2 -3
- package/bin/operation/find.js +33 -199
- package/bin/operation/previousRule.js +39 -0
- package/bin/operation/prompt/previousRule.js +52 -0
- package/bin/operation/prompt/rule.js +17 -5
- package/bin/operation/rule.js +2 -2
- package/bin/options.js +2 -0
- package/bin/rule/glob.js +27 -5
- package/bin/rule/regex.js +27 -5
- package/bin/rule/string.js +35 -15
- package/bin/utilities/find.js +203 -0
- package/bin/utilities/prompt.js +124 -2
- package/bin/utilities/string.js +0 -3
- package/bin/versions.js +4 -2
- package/package.json +2 -2
- package/bin/operation/readConfiguration.js +0 -27
package/bin/utilities/prompt.js
CHANGED
|
@@ -1,7 +1,129 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const { encodings, characters } = require("necessary");
|
|
4
|
+
|
|
5
|
+
const { DATA } = require("../constants"),
|
|
6
|
+
{ PREVIOUS_GLOB_STRING_OR_REGEX_DESCRIPTION } = require("../descriptions");
|
|
7
|
+
|
|
8
|
+
const { UTF8_ENCODING } = encodings,
|
|
9
|
+
{ UP_CHARACTER,
|
|
10
|
+
ETX_CHARACTER,
|
|
11
|
+
DOWN_CHARACTER,
|
|
12
|
+
ESCAPE_CHARACTER,
|
|
13
|
+
CTRL_C_CHARACTER,
|
|
14
|
+
NEW_LINE_CHARACTER,
|
|
15
|
+
CARRIAGE_RETURN_CHARACTER } = characters;
|
|
16
|
+
|
|
17
|
+
function selectPreviousRule(previousRules, callback) {
|
|
18
|
+
let index = 0,
|
|
19
|
+
previousRule = previousRules[index];
|
|
20
|
+
|
|
21
|
+
writePreviousRule(previousRule);
|
|
22
|
+
|
|
23
|
+
const rawMode = true,
|
|
24
|
+
encoding = UTF8_ENCODING,
|
|
25
|
+
previousRulesLength = previousRules.length;
|
|
26
|
+
|
|
27
|
+
process.stdin.setRawMode(rawMode);
|
|
28
|
+
|
|
29
|
+
process.stdin.setEncoding(encoding);
|
|
30
|
+
|
|
31
|
+
process.stdin.addListener(DATA, listener);
|
|
32
|
+
|
|
33
|
+
process.stdin.resume();
|
|
34
|
+
|
|
35
|
+
function listener(data) {
|
|
36
|
+
const character = data.toString(encoding);
|
|
37
|
+
|
|
38
|
+
switch (character) {
|
|
39
|
+
case UP_CHARACTER: {
|
|
40
|
+
const firstIndex = 0;
|
|
41
|
+
|
|
42
|
+
if (index > firstIndex) {
|
|
43
|
+
index--;
|
|
44
|
+
|
|
45
|
+
previousRule = previousRules[index];
|
|
46
|
+
|
|
47
|
+
writePreviousRule(previousRule);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
case DOWN_CHARACTER: {
|
|
54
|
+
const lastIndex = previousRulesLength - 1;
|
|
55
|
+
|
|
56
|
+
if (index < lastIndex) {
|
|
57
|
+
index++;
|
|
58
|
+
|
|
59
|
+
previousRule = previousRules[index];
|
|
60
|
+
|
|
61
|
+
writePreviousRule(previousRule);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
case ESCAPE_CHARACTER: {
|
|
68
|
+
previousRule = null;
|
|
69
|
+
|
|
70
|
+
console.log(CARRIAGE_RETURN_CHARACTER);
|
|
71
|
+
|
|
72
|
+
process.stdin.removeListener(DATA, listener);
|
|
73
|
+
|
|
74
|
+
process.stdin.pause();
|
|
75
|
+
|
|
76
|
+
callback(previousRule);
|
|
77
|
+
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
case NEW_LINE_CHARACTER:
|
|
82
|
+
case CARRIAGE_RETURN_CHARACTER: {
|
|
83
|
+
process.stdout.clearLine();
|
|
84
|
+
|
|
85
|
+
process.stdout.cursorTo(0);
|
|
86
|
+
|
|
87
|
+
process.stdin.removeListener(DATA, listener);
|
|
88
|
+
|
|
89
|
+
process.stdin.pause();
|
|
90
|
+
|
|
91
|
+
callback(previousRule);
|
|
92
|
+
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
case ETX_CHARACTER: {
|
|
97
|
+
console.log(CTRL_C_CHARACTER);
|
|
98
|
+
|
|
99
|
+
process.exit();
|
|
100
|
+
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
default: {
|
|
105
|
+
///
|
|
106
|
+
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
4
112
|
|
|
5
113
|
module.exports = {
|
|
6
|
-
|
|
114
|
+
selectPreviousRule
|
|
7
115
|
};
|
|
116
|
+
|
|
117
|
+
function writePreviousRule(previousRule) {
|
|
118
|
+
const description = PREVIOUS_GLOB_STRING_OR_REGEX_DESCRIPTION, ///
|
|
119
|
+
previousRuleString = previousRule.asString();
|
|
120
|
+
|
|
121
|
+
process.stdout.clearLine();
|
|
122
|
+
|
|
123
|
+
process.stdout.cursorTo(0);
|
|
124
|
+
|
|
125
|
+
process.stdout.write(description);
|
|
126
|
+
|
|
127
|
+
process.stdout.write(previousRuleString);
|
|
128
|
+
}
|
|
129
|
+
|
package/bin/utilities/string.js
CHANGED
|
@@ -6,8 +6,6 @@ function addAnchors(string) { return `^${string}$`; }
|
|
|
6
6
|
|
|
7
7
|
function removeAnchors(string) { return string.replace(/(^\^|\$$)/g, EMPTY_STRING); }
|
|
8
8
|
|
|
9
|
-
function addDoubleQuotes(string) { return `"${string}"`; }
|
|
10
|
-
|
|
11
9
|
function addForwardSlashes(string) { return `/${string}/`; }
|
|
12
10
|
|
|
13
11
|
function removeDoubleQuotes(string) { return string.replace(/(^"|"$)/g, EMPTY_STRING); }
|
|
@@ -25,7 +23,6 @@ function removeTrailingEscapedForwardSlash(string) { return string.replace(/(\\\
|
|
|
25
23
|
module.exports = {
|
|
26
24
|
addAnchors,
|
|
27
25
|
removeAnchors,
|
|
28
|
-
addDoubleQuotes,
|
|
29
26
|
addForwardSlashes,
|
|
30
27
|
removeDoubleQuotes,
|
|
31
28
|
removeForwardSlashes,
|
package/bin/versions.js
CHANGED
|
@@ -4,12 +4,14 @@ const VERSION_1_0 = "1.0",
|
|
|
4
4
|
VERSION_1_1 = "1.1",
|
|
5
5
|
VERSION_1_2 = "1.2",
|
|
6
6
|
VERSION_1_3 = "1.3",
|
|
7
|
-
VERSION_1_4 = "1.4"
|
|
7
|
+
VERSION_1_4 = "1.4",
|
|
8
|
+
VERSION_1_7 = "1.7";
|
|
8
9
|
|
|
9
10
|
module.exports = {
|
|
10
11
|
VERSION_1_0,
|
|
11
12
|
VERSION_1_1,
|
|
12
13
|
VERSION_1_2,
|
|
13
14
|
VERSION_1_3,
|
|
14
|
-
VERSION_1_4
|
|
15
|
+
VERSION_1_4,
|
|
16
|
+
VERSION_1_7
|
|
15
17
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "find-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.1",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/find-cli",
|
|
7
7
|
"description": "An alternative to grep.",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"argumentative": "^2.0.32",
|
|
17
|
-
"necessary": "^14.2.
|
|
17
|
+
"necessary": "^14.2.4"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {}
|
|
20
20
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { retrieveRootDirectoryPaths,
|
|
4
|
-
retrieveIgnoredFilePathRules,
|
|
5
|
-
retrievePermittedFilePathRules,
|
|
6
|
-
retrieveIgnoredDirectoryPathRules,
|
|
7
|
-
retrievePermittedDirectoryPathRules } = require("../configuration");
|
|
8
|
-
|
|
9
|
-
function readConfigurationOperation(proceed, abort, context) {
|
|
10
|
-
const rootDirectoryPaths = retrieveRootDirectoryPaths(),
|
|
11
|
-
ignoredFilePathRules = retrieveIgnoredFilePathRules(),
|
|
12
|
-
permittedFilePathRules = retrievePermittedFilePathRules(),
|
|
13
|
-
ignoredDirectoryPathRules = retrieveIgnoredDirectoryPathRules(),
|
|
14
|
-
permittedDirectoryPathRules = retrievePermittedDirectoryPathRules();
|
|
15
|
-
|
|
16
|
-
Object.assign(context, {
|
|
17
|
-
rootDirectoryPaths,
|
|
18
|
-
ignoredFilePathRules,
|
|
19
|
-
permittedFilePathRules,
|
|
20
|
-
ignoredDirectoryPathRules,
|
|
21
|
-
permittedDirectoryPathRules
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
proceed();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = readConfigurationOperation;
|