secrez 2.1.4 → 2.1.5
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 +4 -0
- package/package.json +1 -1
- package/src/commands/Touch.js +31 -2
package/README.md
CHANGED
@@ -369,6 +369,10 @@ Secrez is not intended to compete with password managers, so do not expect it to
|
|
369
369
|
|
370
370
|
## History
|
371
371
|
|
372
|
+
**2.1.5**
|
373
|
+
|
374
|
+
- duplicate files using `touch <newfile> --from <file>` to copy the file from the source to the destination
|
375
|
+
|
372
376
|
**2.1.4**
|
373
377
|
|
374
378
|
- uses clipboard only on macOS
|
package/package.json
CHANGED
package/src/commands/Touch.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
const { config, Entry } = require("@secrez/core");
|
2
2
|
const { yamlStringify } = require("@secrez/utils");
|
3
3
|
const { newWallet, getWalletFromMnemonic } = require("@secrez/eth");
|
4
|
+
const { Node } = require("@secrez/fs");
|
4
5
|
|
5
6
|
class Touch extends require("../Command") {
|
6
7
|
setHelpAndCompletion() {
|
@@ -62,6 +63,11 @@ class Touch extends require("../Command") {
|
|
62
63
|
alias: "v",
|
63
64
|
type: Boolean,
|
64
65
|
},
|
66
|
+
{
|
67
|
+
name: "from",
|
68
|
+
type: String,
|
69
|
+
completionType: "file",
|
70
|
+
},
|
65
71
|
];
|
66
72
|
}
|
67
73
|
|
@@ -77,8 +83,10 @@ class Touch extends require("../Command") {
|
|
77
83
|
"touch somefile",
|
78
84
|
"If the the file exists, it create 'somefile.2', 'somefile.3', etc.",
|
79
85
|
],
|
80
|
-
|
81
|
-
|
86
|
+
[
|
87
|
+
'touch -p afile --content "Password: 1432874565"',
|
88
|
+
"Save the specified content in 'afile'.",
|
89
|
+
],
|
82
90
|
[
|
83
91
|
"touch sample.txt -w",
|
84
92
|
"Prompt the user to type the content of the file. The text cannot contain newlines. It will cut at the first one, if so. If '-w' and '-c' are both present, '-c' will be ignored.",
|
@@ -107,6 +115,10 @@ class Touch extends require("../Command") {
|
|
107
115
|
"touch new-wallets.yaml -gi",
|
108
116
|
"Includes the mnemonic. In this case, it will also add the fields 'mnemonic' (mnemonic phrase) and 'derived_path' (path used to generate the keys). ",
|
109
117
|
],
|
118
|
+
[
|
119
|
+
"touch wallet2.yml --from wallet.yaml",
|
120
|
+
"Creates the new file 'wallet2.yml' duplicating 'wallet.yml'.",
|
121
|
+
],
|
110
122
|
],
|
111
123
|
};
|
112
124
|
}
|
@@ -193,6 +205,23 @@ class Touch extends require("../Command") {
|
|
193
205
|
} else {
|
194
206
|
throw new Error("Command canceled");
|
195
207
|
}
|
208
|
+
} else if (options.from) {
|
209
|
+
let data = await this.internalFs.getTreeIndexAndPath(options.from);
|
210
|
+
let tree = data.tree;
|
211
|
+
let p = tree.getNormalizedPath(data.path);
|
212
|
+
let node;
|
213
|
+
try {
|
214
|
+
node = tree.root.getChildFromPath(p);
|
215
|
+
} catch (e) {
|
216
|
+
throw new Error(`File "${options.from}" not found.`);
|
217
|
+
}
|
218
|
+
if (Node.isFile(node)) {
|
219
|
+
console.log("is file");
|
220
|
+
let details = await tree.getEntryDetails(node);
|
221
|
+
options.content = details.content;
|
222
|
+
} else {
|
223
|
+
throw new Error(`"${options.from}" is not a file.`);
|
224
|
+
}
|
196
225
|
}
|
197
226
|
}
|
198
227
|
let newFile = await this.touch(options);
|