secrez 1.1.0 → 1.1.2
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/LICENSE +21 -0
- package/README.md +414 -291
- package/bin/secrez.js +50 -47
- package/coverage.report +81 -0
- package/package.json +18 -20
- package/src/Command.js +78 -57
- package/src/PreCommand.js +74 -70
- package/src/Welcome.js +144 -134
- package/src/cliConfig.js +14 -14
- package/src/commands/Alias.js +123 -100
- package/src/commands/Bash.js +10 -12
- package/src/commands/Cat.js +117 -107
- package/src/commands/Cd.js +39 -42
- package/src/commands/Chat.js +75 -63
- package/src/commands/Conf.js +123 -99
- package/src/commands/Contacts.js +189 -171
- package/src/commands/Copy.js +132 -113
- package/src/commands/Courier.js +123 -105
- package/src/commands/Ds.js +88 -76
- package/src/commands/Edit.js +122 -103
- package/src/commands/Export.js +153 -114
- package/src/commands/Find.js +115 -110
- package/src/commands/Help.js +20 -23
- package/src/commands/Import.js +296 -225
- package/src/commands/Lcat.js +36 -39
- package/src/commands/Lcd.js +38 -39
- package/src/commands/Lls.js +58 -55
- package/src/commands/Lpwd.js +20 -24
- package/src/commands/Ls.js +107 -97
- package/src/commands/Mkdir.js +35 -38
- package/src/commands/Mv.js +147 -114
- package/src/commands/Paste.js +68 -65
- package/src/commands/Pwd.js +18 -23
- package/src/commands/Quit.js +22 -24
- package/src/commands/Rm.js +78 -70
- package/src/commands/Shell.js +31 -32
- package/src/commands/Ssh.js +77 -63
- package/src/commands/Tag.js +133 -112
- package/src/commands/Totp.js +166 -136
- package/src/commands/Touch.js +169 -56
- package/src/commands/Use.js +44 -41
- package/src/commands/Ver.js +16 -18
- package/src/commands/Whoami.js +34 -37
- package/src/commands/chat/Contacts.js +41 -44
- package/src/commands/chat/Help.js +20 -23
- package/src/commands/chat/Join.js +59 -55
- package/src/commands/chat/Leave.js +16 -22
- package/src/commands/chat/Quit.js +19 -24
- package/src/commands/chat/Send.js +58 -57
- package/src/commands/chat/Show.js +60 -51
- package/src/commands/chat/Whoami.js +18 -22
- package/src/commands/index.js +20 -22
- package/src/index.js +3 -3
- package/src/prompts/ChatPrompt.js +87 -82
- package/src/prompts/ChatPromptMock.js +11 -17
- package/src/prompts/CommandPrompt.js +146 -138
- package/src/prompts/Completion.js +64 -69
- package/src/prompts/MainPrompt.js +84 -77
- package/src/prompts/MainPromptMock.js +19 -30
- package/src/prompts/MultiEditorPrompt.js +21 -22
- package/src/prompts/SigintManager.js +21 -24
- package/src/utils/AliasManager.js +16 -18
- package/src/utils/ContactManager.js +15 -17
- package/src/utils/Fido2Client.js +59 -49
- package/src/utils/HelpProto.js +130 -117
- package/src/utils/Logger.js +48 -50
- package/.eslintignore +0 -0
- package/.eslintrc +0 -33
- package/.jshintrc +0 -3
package/src/commands/Mv.js
CHANGED
@@ -1,211 +1,244 @@
|
|
1
|
-
const _ = require(
|
2
|
-
const {Node} = require(
|
3
|
-
|
4
|
-
class Mv extends require('../Command') {
|
1
|
+
const _ = require("lodash");
|
2
|
+
const { Node } = require("@secrez/fs");
|
5
3
|
|
4
|
+
class Mv extends require("../Command") {
|
6
5
|
setHelpAndCompletion() {
|
7
6
|
this.cliConfig.completion.mv = {
|
8
7
|
_func: this.selfCompletion(this),
|
9
|
-
_self: this
|
10
|
-
}
|
11
|
-
this.cliConfig.completion.help.mv = true
|
8
|
+
_self: this,
|
9
|
+
};
|
10
|
+
this.cliConfig.completion.help.mv = true;
|
12
11
|
this.optionDefinitions = [
|
13
12
|
{
|
14
|
-
name:
|
15
|
-
alias:
|
16
|
-
type: Boolean
|
13
|
+
name: "help",
|
14
|
+
alias: "h",
|
15
|
+
type: Boolean,
|
17
16
|
},
|
18
17
|
{
|
19
|
-
name:
|
20
|
-
completionType:
|
21
|
-
alias:
|
18
|
+
name: "path",
|
19
|
+
completionType: "file",
|
20
|
+
alias: "p",
|
22
21
|
defaultOption: true,
|
23
22
|
multiple: true,
|
24
|
-
type: String
|
23
|
+
type: String,
|
25
24
|
},
|
26
25
|
{
|
27
|
-
name:
|
28
|
-
type: String
|
26
|
+
name: "find",
|
27
|
+
type: String,
|
29
28
|
},
|
30
29
|
{
|
31
|
-
name:
|
32
|
-
alias:
|
33
|
-
type: String
|
30
|
+
name: "destination",
|
31
|
+
alias: "d",
|
32
|
+
type: String,
|
34
33
|
},
|
35
34
|
{
|
36
|
-
name:
|
37
|
-
type: Boolean
|
35
|
+
name: "content-too",
|
36
|
+
type: Boolean,
|
38
37
|
},
|
39
38
|
{
|
40
|
-
name:
|
41
|
-
type: Boolean
|
42
|
-
}
|
43
|
-
]
|
39
|
+
name: "span",
|
40
|
+
type: Boolean,
|
41
|
+
},
|
42
|
+
];
|
44
43
|
}
|
45
44
|
|
46
45
|
help() {
|
47
46
|
return {
|
48
|
-
description: [
|
49
|
-
|
47
|
+
description: [
|
48
|
+
"Moves and renames files or folders.",
|
49
|
+
"If a destination is not specified it tries to move to the current folder.",
|
50
|
+
],
|
50
51
|
examples: [
|
51
|
-
|
52
|
-
|
53
|
-
[
|
54
|
-
|
55
|
-
|
52
|
+
"mv somefile someother",
|
53
|
+
"mv -p ../dir1/file -d ../dir1/file-renamed",
|
54
|
+
[
|
55
|
+
"mv pass/email* emails",
|
56
|
+
"moves all the files starting from email contained in pass",
|
57
|
+
],
|
58
|
+
[
|
59
|
+
"mv pass/email* archive:/old/email",
|
60
|
+
"moves all the files starting from email contained in pass",
|
56
61
|
'to the folder "/old/email" in the "archive" dataset;',
|
57
|
-
|
62
|
+
"The autocomplete works only in the current dataset (for now)",
|
58
63
|
],
|
59
|
-
[
|
60
|
-
|
61
|
-
|
64
|
+
[
|
65
|
+
"mv archive:/old/email/* /old-email",
|
66
|
+
"moves all the files starting from email contained in /old/email",
|
67
|
+
'in the "archive" dataset to the folder "/old-email" in the current dataset',
|
62
68
|
],
|
63
|
-
[
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
[
|
70
|
+
"mv --find email -d /emails",
|
71
|
+
"moves all the files found searching email to /emails;",
|
72
|
+
],
|
73
|
+
[
|
74
|
+
"mv --find email -d /emails --content-too",
|
75
|
+
"moves all the files found searching email in paths and contents",
|
76
|
+
],
|
77
|
+
[
|
78
|
+
"mv --find email -d archive:/emails --span ",
|
79
|
+
"moves all the files flattening the results",
|
80
|
+
],
|
81
|
+
],
|
82
|
+
};
|
68
83
|
}
|
69
84
|
|
70
85
|
async mv(options, nodes) {
|
71
|
-
let dataFrom = await this.internalFs.getTreeIndexAndPath(options.path)
|
72
|
-
await this.internalFs.mountTree(dataFrom.index)
|
73
|
-
let dataTo = await this.internalFs.getTreeIndexAndPath(options.newPath)
|
86
|
+
let dataFrom = await this.internalFs.getTreeIndexAndPath(options.path);
|
87
|
+
await this.internalFs.mountTree(dataFrom.index);
|
88
|
+
let dataTo = await this.internalFs.getTreeIndexAndPath(options.newPath);
|
74
89
|
if (dataFrom.index !== dataTo.index) {
|
75
|
-
await this.internalFs.mountTree(dataTo.index)
|
76
|
-
} else
|
77
|
-
|
78
|
-
if (dataFrom.index === 1 && options.removing) {
|
90
|
+
await this.internalFs.mountTree(dataTo.index);
|
91
|
+
} else if (dataFrom.index === 1 && options.removing) {
|
92
|
+
/* istanbul ignore if */
|
79
93
|
let yes = await this.useConfirm({
|
80
|
-
message:
|
81
|
-
|
82
|
-
|
94
|
+
message:
|
95
|
+
"Are you sure you want to definitely remove those file from Secrez?",
|
96
|
+
default: false,
|
97
|
+
});
|
83
98
|
if (!yes) {
|
84
|
-
throw new Error(
|
99
|
+
throw new Error("Operation canceled");
|
85
100
|
}
|
86
101
|
}
|
87
102
|
if (nodes) {
|
88
|
-
this.internalFs.trees[dataFrom.index].disableSave()
|
89
|
-
this.internalFs.trees[dataTo.index].disableSave()
|
103
|
+
this.internalFs.trees[dataFrom.index].disableSave();
|
104
|
+
this.internalFs.trees[dataTo.index].disableSave();
|
90
105
|
for (let node of nodes) {
|
91
|
-
let opt = _.clone(options)
|
92
|
-
await this.internalFs.change(
|
106
|
+
let opt = _.clone(options);
|
107
|
+
await this.internalFs.change(
|
108
|
+
Object.assign(opt, { path: `${dataFrom.name}:${node.getPath()}` })
|
109
|
+
);
|
93
110
|
}
|
94
|
-
this.internalFs.trees[dataFrom.index].enableSave()
|
95
|
-
await this.internalFs.trees[dataFrom.index].save()
|
111
|
+
this.internalFs.trees[dataFrom.index].enableSave();
|
112
|
+
await this.internalFs.trees[dataFrom.index].save();
|
96
113
|
if (dataFrom.index !== dataTo.index) {
|
97
|
-
this.internalFs.trees[dataTo.index].enableSave()
|
98
|
-
await this.internalFs.trees[dataTo.index].save()
|
114
|
+
this.internalFs.trees[dataTo.index].enableSave();
|
115
|
+
await this.internalFs.trees[dataTo.index].save();
|
99
116
|
}
|
100
117
|
} else {
|
101
|
-
await this.internalFs.change(options)
|
118
|
+
await this.internalFs.change(options);
|
102
119
|
}
|
103
120
|
}
|
104
121
|
|
105
122
|
async isNotDir(options = {}) {
|
106
|
-
let dir
|
123
|
+
let dir;
|
107
124
|
try {
|
108
|
-
let data = await this.internalFs.getTreeIndexAndPath(
|
109
|
-
|
110
|
-
|
125
|
+
let data = await this.internalFs.getTreeIndexAndPath(
|
126
|
+
options.newPath || ""
|
127
|
+
);
|
128
|
+
let to = data.name;
|
129
|
+
let index = this.internalFs.tree.datasetIndex;
|
111
130
|
if (to) {
|
112
|
-
let datasetInfo = await this.internalFs.getDatasetInfo(to)
|
131
|
+
let datasetInfo = await this.internalFs.getDatasetInfo(to);
|
113
132
|
if (!datasetInfo) {
|
114
|
-
throw new Error(
|
133
|
+
throw new Error("Destination dataset does not exist");
|
115
134
|
}
|
116
|
-
index = datasetInfo.index
|
117
|
-
await this.internalFs.mountTree(index)
|
135
|
+
index = datasetInfo.index;
|
136
|
+
await this.internalFs.mountTree(index);
|
118
137
|
}
|
119
|
-
let p = this.internalFs.normalizePath(data.path, index)
|
120
|
-
dir = this.internalFs.trees[index].root.getChildFromPath(p)
|
121
|
-
} catch (e) {
|
122
|
-
|
123
|
-
return !(dir && Node.isDir(dir))
|
138
|
+
let p = this.internalFs.normalizePath(data.path, index);
|
139
|
+
dir = this.internalFs.trees[index].root.getChildFromPath(p);
|
140
|
+
} catch (e) {}
|
141
|
+
return !(dir && Node.isDir(dir));
|
124
142
|
}
|
125
143
|
|
126
144
|
async exec(options = {}) {
|
127
145
|
if (options.help) {
|
128
|
-
return this.showHelp()
|
146
|
+
return this.showHelp();
|
129
147
|
}
|
130
148
|
try {
|
131
|
-
this.validate(options)
|
149
|
+
this.validate(options);
|
132
150
|
if (options.find) {
|
133
|
-
options.newPath = options.destination
|
134
|
-
options.path = options.find
|
151
|
+
options.newPath = options.destination;
|
152
|
+
options.path = options.find;
|
135
153
|
} else {
|
136
154
|
if (options.destination) {
|
137
|
-
options.newPath = options.destination
|
138
|
-
|
155
|
+
options.newPath = options.destination;
|
139
156
|
} else {
|
140
|
-
options.newPath = options.path[1]
|
157
|
+
options.newPath = options.path[1];
|
141
158
|
}
|
142
|
-
options.path = options.path[0]
|
159
|
+
options.path = options.path[0];
|
143
160
|
}
|
144
161
|
if (!options.path && !options.find) {
|
145
|
-
throw new Error(
|
162
|
+
throw new Error("An origin path is required.");
|
146
163
|
} else {
|
147
164
|
if (!options.newPath) {
|
148
|
-
options.message =
|
149
|
-
|
150
|
-
|
165
|
+
options.message =
|
166
|
+
"Destination not set.\nWould you like to move to the current active directory in the target dataset?";
|
167
|
+
options.default = false;
|
168
|
+
let yes = await this.useConfirm(options);
|
151
169
|
if (yes) {
|
152
|
-
options.newPath =
|
170
|
+
options.newPath = ".";
|
153
171
|
} else {
|
154
|
-
throw new Error(
|
172
|
+
throw new Error("Operation canceled");
|
155
173
|
}
|
156
174
|
}
|
157
|
-
let dataFrom = await this.internalFs.getTreeIndexAndPath(options.path)
|
158
|
-
let mustBeFolder = options.find || /\?|\*/.test(options.path)
|
159
|
-
let nodes
|
175
|
+
let dataFrom = await this.internalFs.getTreeIndexAndPath(options.path);
|
176
|
+
let mustBeFolder = options.find || /\?|\*/.test(options.path);
|
177
|
+
let nodes;
|
160
178
|
if (options.find) {
|
161
|
-
options.getNodes = true
|
162
|
-
options.name = options.find
|
163
|
-
options.content = options.contentToo
|
164
|
-
nodes = await this.prompt.commands.find.find(options)
|
179
|
+
options.getNodes = true;
|
180
|
+
options.name = options.find;
|
181
|
+
options.content = options.contentToo;
|
182
|
+
nodes = await this.prompt.commands.find.find(options);
|
165
183
|
if (!options.span) {
|
166
184
|
for (let i = 0; i < nodes.length; i++) {
|
167
185
|
if (i > 0) {
|
168
186
|
if (Node.isAncestor(nodes[i - 1], nodes[i])) {
|
169
|
-
nodes.splice(i, 1)
|
170
|
-
i
|
187
|
+
nodes.splice(i, 1);
|
188
|
+
i--;
|
171
189
|
}
|
172
190
|
}
|
173
191
|
}
|
174
192
|
}
|
175
193
|
} else {
|
176
|
-
nodes = await this.internalFs.fileList(
|
177
|
-
|
178
|
-
|
179
|
-
|
194
|
+
nodes = await this.internalFs.fileList(
|
195
|
+
{
|
196
|
+
path: options.path,
|
197
|
+
asIs: true,
|
198
|
+
},
|
199
|
+
null,
|
200
|
+
true
|
201
|
+
);
|
180
202
|
}
|
181
203
|
if (nodes.length) {
|
182
204
|
if (mustBeFolder) {
|
183
205
|
if (await this.isNotDir(options)) {
|
184
|
-
throw new Error(
|
206
|
+
throw new Error(
|
207
|
+
"When using search results or wildcards, the target has to be a folder"
|
208
|
+
);
|
185
209
|
}
|
186
210
|
}
|
187
|
-
let paths = nodes.map(e => [e.getPath(), e.id])
|
188
|
-
await this.mv(
|
211
|
+
let paths = nodes.map((e) => [e.getPath(), e.id]);
|
212
|
+
await this.mv(
|
213
|
+
Object.assign(options, { newPath: options.newPath }),
|
214
|
+
nodes
|
215
|
+
);
|
189
216
|
if (options.find) {
|
190
|
-
this.Logger.reset(
|
217
|
+
this.Logger.reset(
|
218
|
+
`The results of searching for ${options.find} has been moved to ${options.newPath}`
|
219
|
+
);
|
191
220
|
} else {
|
192
|
-
this.Logger.reset(
|
193
|
-
let data = await this.internalFs.getTreeIndexAndPath(
|
221
|
+
this.Logger.reset("The following have been moved:");
|
222
|
+
let data = await this.internalFs.getTreeIndexAndPath(
|
223
|
+
options.newPath || ""
|
224
|
+
);
|
194
225
|
for (let p of paths) {
|
195
|
-
this.Logger.reset(
|
226
|
+
this.Logger.reset(
|
227
|
+
`${dataFrom.name}:${p[0]} > ${data.name}:${data.tree.root
|
228
|
+
.findChildById(p[1])
|
229
|
+
.getPath()}`
|
230
|
+
);
|
196
231
|
}
|
197
232
|
}
|
198
233
|
} else {
|
199
|
-
this.Logger.red(
|
234
|
+
this.Logger.red("Path does not exist");
|
200
235
|
}
|
201
236
|
}
|
202
237
|
} catch (e) {
|
203
|
-
this.Logger.red(e.message)
|
238
|
+
this.Logger.red(e.message);
|
204
239
|
}
|
205
|
-
await this.prompt.run()
|
240
|
+
await this.prompt.run();
|
206
241
|
}
|
207
242
|
}
|
208
243
|
|
209
|
-
module.exports = Mv
|
210
|
-
|
211
|
-
|
244
|
+
module.exports = Mv;
|
package/src/commands/Paste.js
CHANGED
@@ -1,132 +1,135 @@
|
|
1
|
-
const clipboardy = require(
|
2
|
-
const {isYaml, yamlParse, yamlStringify} = require(
|
1
|
+
const clipboardy = require("clipboardy");
|
2
|
+
const { isYaml, yamlParse, yamlStringify } = require("@secrez/utils");
|
3
3
|
|
4
|
-
const {Node} = require(
|
5
|
-
|
6
|
-
class Paste extends require('../Command') {
|
4
|
+
const { Node } = require("@secrez/fs");
|
7
5
|
|
6
|
+
class Paste extends require("../Command") {
|
8
7
|
setHelpAndCompletion() {
|
9
8
|
this.cliConfig.completion.paste = {
|
10
9
|
_func: this.selfCompletion(this),
|
11
|
-
_self: this
|
12
|
-
}
|
13
|
-
this.cliConfig.completion.help.paste = true
|
10
|
+
_self: this,
|
11
|
+
};
|
12
|
+
this.cliConfig.completion.help.paste = true;
|
14
13
|
this.optionDefinitions = [
|
15
14
|
{
|
16
|
-
name:
|
17
|
-
alias:
|
18
|
-
type: Boolean
|
15
|
+
name: "help",
|
16
|
+
alias: "h",
|
17
|
+
type: Boolean,
|
19
18
|
},
|
20
19
|
{
|
21
|
-
name:
|
22
|
-
completionType:
|
23
|
-
alias:
|
20
|
+
name: "path",
|
21
|
+
completionType: "file",
|
22
|
+
alias: "p",
|
24
23
|
defaultOption: true,
|
25
|
-
type: String
|
24
|
+
type: String,
|
26
25
|
},
|
27
26
|
{
|
28
|
-
name:
|
29
|
-
alias:
|
30
|
-
type: Boolean
|
27
|
+
name: "append",
|
28
|
+
alias: "a",
|
29
|
+
type: Boolean,
|
31
30
|
},
|
32
31
|
{
|
33
|
-
name:
|
34
|
-
alias:
|
35
|
-
type: String
|
36
|
-
}
|
37
|
-
]
|
32
|
+
name: "field",
|
33
|
+
alias: "f",
|
34
|
+
type: String,
|
35
|
+
},
|
36
|
+
];
|
38
37
|
}
|
39
38
|
|
40
39
|
help() {
|
41
40
|
return {
|
42
41
|
description: [
|
43
|
-
|
42
|
+
"Paste whatever is in the clipboard in an encrypted entries.",
|
44
43
|
],
|
45
44
|
examples: [
|
46
|
-
[
|
47
|
-
[
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
["paste ethKeys.json", "pastes in ethKeys.json even if it exists"],
|
46
|
+
[
|
47
|
+
"paste -a -p google.txt",
|
48
|
+
"pastes appending the content to the existent content in google.txt",
|
49
|
+
],
|
50
|
+
[
|
51
|
+
"paste yahoo.yml -f password",
|
52
|
+
"pastes the field password in the card",
|
53
|
+
],
|
54
|
+
],
|
55
|
+
};
|
51
56
|
}
|
52
57
|
|
53
58
|
async paste(options = {}) {
|
54
|
-
let ifs = this.internalFs
|
55
|
-
let cat = this.prompt.commands.cat
|
56
|
-
let p = this.internalFs.tree.getNormalizedPath(options.path)
|
57
|
-
let file
|
58
|
-
let existingContent
|
59
|
+
let ifs = this.internalFs;
|
60
|
+
let cat = this.prompt.commands.cat;
|
61
|
+
let p = this.internalFs.tree.getNormalizedPath(options.path);
|
62
|
+
let file;
|
63
|
+
let existingContent;
|
59
64
|
try {
|
60
|
-
file = ifs.tree.root.getChildFromPath(p)
|
61
|
-
existingContent = (await cat.cat({path: p, unformatted: true}))[0]
|
65
|
+
file = ifs.tree.root.getChildFromPath(p);
|
66
|
+
existingContent = (await cat.cat({ path: p, unformatted: true }))[0]
|
67
|
+
.content;
|
62
68
|
} catch (e) {
|
63
69
|
//
|
64
70
|
}
|
65
71
|
if (file && !Node.isFile(file)) {
|
66
|
-
throw new Error(
|
72
|
+
throw new Error("Cannot paste to a folder or a binary file");
|
67
73
|
}
|
68
|
-
let content
|
74
|
+
let content;
|
69
75
|
try {
|
70
|
-
content = await clipboardy.read()
|
76
|
+
content = await clipboardy.read();
|
71
77
|
} catch (e) {
|
72
|
-
throw new Error(e.message)
|
78
|
+
throw new Error(e.message);
|
73
79
|
}
|
74
80
|
if (!content) {
|
75
|
-
throw new Error(
|
81
|
+
throw new Error("The clipboard does not contain any text");
|
76
82
|
}
|
77
83
|
if (isYaml(p) && options.field) {
|
78
|
-
let parsed = {}
|
84
|
+
let parsed = {};
|
79
85
|
if (existingContent) {
|
80
86
|
try {
|
81
|
-
parsed = yamlParse(existingContent)
|
87
|
+
parsed = yamlParse(existingContent);
|
82
88
|
} catch (e) {
|
83
|
-
throw new Error(
|
89
|
+
throw new Error("The yaml file exists but it is malformed.");
|
84
90
|
}
|
85
91
|
}
|
86
|
-
parsed[options.field] = content
|
87
|
-
content = yamlStringify(parsed)
|
92
|
+
parsed[options.field] = content;
|
93
|
+
content = yamlStringify(parsed);
|
88
94
|
}
|
89
95
|
if (file) {
|
90
96
|
if (options.append) {
|
91
|
-
content = existingContent +
|
97
|
+
content = existingContent + "\n" + content;
|
92
98
|
}
|
93
99
|
await ifs.change({
|
94
100
|
path: p,
|
95
|
-
content
|
96
|
-
})
|
101
|
+
content,
|
102
|
+
});
|
97
103
|
} else {
|
98
104
|
await ifs.make({
|
99
105
|
path: p,
|
100
106
|
type: this.cliConfig.types.TEXT,
|
101
|
-
content
|
102
|
-
})
|
107
|
+
content,
|
108
|
+
});
|
103
109
|
}
|
104
110
|
try {
|
105
|
-
await clipboardy.write(
|
111
|
+
await clipboardy.write("");
|
106
112
|
} catch (e) {
|
107
|
-
throw new Error(e.message)
|
113
|
+
throw new Error(e.message);
|
108
114
|
}
|
109
115
|
|
110
|
-
return options.path
|
111
|
-
|
116
|
+
return options.path;
|
112
117
|
}
|
113
118
|
|
114
119
|
async exec(options = {}) {
|
115
120
|
if (options.help) {
|
116
|
-
return this.showHelp()
|
121
|
+
return this.showHelp();
|
117
122
|
}
|
118
123
|
try {
|
119
|
-
this.validate(options)
|
120
|
-
let name = await this.paste(options)
|
121
|
-
this.Logger.grey(
|
122
|
-
this.Logger.reset(name)
|
124
|
+
this.validate(options);
|
125
|
+
let name = await this.paste(options);
|
126
|
+
this.Logger.grey("Pasted the clipboard to:");
|
127
|
+
this.Logger.reset(name);
|
123
128
|
} catch (e) {
|
124
|
-
this.Logger.red(e.message)
|
129
|
+
this.Logger.red(e.message);
|
125
130
|
}
|
126
|
-
await this.prompt.run()
|
131
|
+
await this.prompt.run();
|
127
132
|
}
|
128
133
|
}
|
129
134
|
|
130
|
-
module.exports = Paste
|
131
|
-
|
132
|
-
|
135
|
+
module.exports = Paste;
|
package/src/commands/Pwd.js
CHANGED
@@ -1,44 +1,39 @@
|
|
1
|
-
class Pwd extends require(
|
2
|
-
|
1
|
+
class Pwd extends require("../Command") {
|
3
2
|
setHelpAndCompletion() {
|
4
|
-
this.cliConfig.completion.pwd = {}
|
5
|
-
this.cliConfig.completion.help.pwd = true
|
3
|
+
this.cliConfig.completion.pwd = {};
|
4
|
+
this.cliConfig.completion.help.pwd = true;
|
6
5
|
this.optionDefinitions = [
|
7
6
|
{
|
8
|
-
name:
|
9
|
-
alias:
|
10
|
-
type: Boolean
|
11
|
-
}
|
12
|
-
]
|
7
|
+
name: "help",
|
8
|
+
alias: "h",
|
9
|
+
type: Boolean,
|
10
|
+
},
|
11
|
+
];
|
13
12
|
}
|
14
13
|
|
15
14
|
help() {
|
16
15
|
return {
|
17
|
-
description: [
|
18
|
-
examples: [
|
19
|
-
|
20
|
-
]
|
21
|
-
}
|
16
|
+
description: ["Shows the path of the working directory."],
|
17
|
+
examples: ["pwd"],
|
18
|
+
};
|
22
19
|
}
|
23
20
|
|
24
21
|
async pwd() {
|
25
|
-
return this.internalFs.tree.workingNode.getPath()
|
22
|
+
return this.internalFs.tree.workingNode.getPath();
|
26
23
|
}
|
27
24
|
|
28
25
|
async exec(options = {}) {
|
29
26
|
if (options.help) {
|
30
|
-
return this.showHelp()
|
27
|
+
return this.showHelp();
|
31
28
|
}
|
32
29
|
try {
|
33
|
-
this.validate(options)
|
34
|
-
this.Logger.reset(await this.pwd())
|
30
|
+
this.validate(options);
|
31
|
+
this.Logger.reset(await this.pwd());
|
35
32
|
} catch (e) {
|
36
|
-
this.Logger.red(e.message)
|
33
|
+
this.Logger.red(e.message);
|
37
34
|
}
|
38
|
-
await this.prompt.run()
|
35
|
+
await this.prompt.run();
|
39
36
|
}
|
40
37
|
}
|
41
38
|
|
42
|
-
module.exports = Pwd
|
43
|
-
|
44
|
-
|
39
|
+
module.exports = Pwd;
|