bcup-cli 1.0.13 → 1.1.0
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/package.json +1 -1
- package/src/cli.ts +14 -7
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -15,6 +15,7 @@ export function cli(args) {
|
|
|
15
15
|
const chalk = require('chalk');
|
|
16
16
|
const prompt = require('prompt-sync')();
|
|
17
17
|
const password = prompt('Vault password: ', { echo: '*' })
|
|
18
|
+
if (password == undefined || password.length == 0) return
|
|
18
19
|
|
|
19
20
|
init();
|
|
20
21
|
const datasourceCredentials = Credentials.fromDatasource({
|
|
@@ -34,7 +35,7 @@ export function cli(args) {
|
|
|
34
35
|
do {
|
|
35
36
|
console.log("\n");
|
|
36
37
|
const titleSearch = prompt('Search text in folder or title. You can use RegExp: ')
|
|
37
|
-
const re = new RegExp(titleSearch, '
|
|
38
|
+
const re = new RegExp(titleSearch, 'i');
|
|
38
39
|
entries = vault.findEntriesByProperty('title', re);
|
|
39
40
|
const groups = vault.findGroupsByTitle(re);
|
|
40
41
|
const groupEntries = groups.map(group => group.getEntries());
|
|
@@ -43,18 +44,23 @@ export function cli(args) {
|
|
|
43
44
|
entries = uniqBy(entries, entry => entry.id);
|
|
44
45
|
console.log('0 exit');
|
|
45
46
|
entries.forEach((entry, idx) => {
|
|
46
|
-
const title = emphSearch(entry.getProperty('title'),
|
|
47
|
+
const title = emphSearch(entry.getProperty('title'), titleSearch);
|
|
47
48
|
const username = entry.getProperty('username');
|
|
48
49
|
const url = entry.getProperty('URL');
|
|
49
|
-
const group = emphSearch(entry.getGroup().getTitle(),
|
|
50
|
+
const group = emphSearch(entry.getGroup().getTitle(), titleSearch);
|
|
50
51
|
const sep = ` ${chalk.bold('|')} `
|
|
51
52
|
console.log(`${idx + 1} ${group}${chalk.bold('->')}${title}${sep}url: ${url}${sep}username: ${username}`);
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
console.log("\n");
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
do {
|
|
57
|
+
num = prompt('Select entry to copy or enter for search again: ')
|
|
58
|
+
if (debug) console.log('num: "'+ num + '"');
|
|
59
|
+
if (num == undefined || (num.length > 0 && (!num.match(/\d+/) || num > entries.length || num < 0))) {
|
|
60
|
+
console.log(`wrong selection (0-${entries.length})`)
|
|
61
|
+
}
|
|
62
|
+
if (num === '0') return;
|
|
63
|
+
} while (num == undefined || num.length > 0 && (!num.match(/\d+/) || num > entries.length || num < 0))
|
|
58
64
|
if (num === '') continue;
|
|
59
65
|
const pass = entries[num - 1].getProperty('password');
|
|
60
66
|
clipboardy.writeSync(pass);
|
|
@@ -66,8 +72,9 @@ export function cli(args) {
|
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
|
|
69
|
-
function emphSearch(string,
|
|
75
|
+
function emphSearch(string, titleSearch) {
|
|
70
76
|
const chalk = require('chalk');
|
|
77
|
+
const re = new RegExp(titleSearch, 'ig');
|
|
71
78
|
|
|
72
79
|
let res;
|
|
73
80
|
let newString = string;
|