@harborppm/cli 0.116.0 → 0.118.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/dist/app.mjs +786 -191
- package/dist/words.mjs +19 -9
- package/lib/cli.mjs +367 -120
- package/lib/format.mjs +59 -0
- package/package.json +1 -1
package/dist/words.mjs
CHANGED
|
@@ -86,6 +86,23 @@ const WHEN = [
|
|
|
86
86
|
].join("|");
|
|
87
87
|
const LEAD = "(?:by|due|due on|due by|on|before|until|till)";
|
|
88
88
|
/** The day a phrase names, or null when it names none. */
|
|
89
|
+
/**
|
|
90
|
+
* The one person a name key ("sam", "samrivera", loosened) means: the full
|
|
91
|
+
* name, else the first name, else (three letters or more) the one name it
|
|
92
|
+
* starts. Two people who fit means nobody.
|
|
93
|
+
*/
|
|
94
|
+
function personForKey(key, people) {
|
|
95
|
+
const full = people.filter((p) => loose(p.name) === key);
|
|
96
|
+
if (full.length === 1) return full[0];
|
|
97
|
+
const first = people.filter((p) => loose(p.name.split(/\s+/)[0] ?? "") === key);
|
|
98
|
+
if (first.length === 1) return first[0];
|
|
99
|
+
const begins = people.filter((p) => loose(p.name).startsWith(key));
|
|
100
|
+
return key.length >= 3 && begins.length === 1 ? begins[0] : null;
|
|
101
|
+
}
|
|
102
|
+
/** "@Sam-R." → "samr": how an @word is compared with names. */
|
|
103
|
+
function looseName(s) {
|
|
104
|
+
return loose(s);
|
|
105
|
+
}
|
|
89
106
|
function dayFromWords(phrase, today) {
|
|
90
107
|
const p = phrase.toLowerCase().replace(/\s+/g, " ").replace(/^on /, "").trim();
|
|
91
108
|
if (p === "today" || p === "tonight") return today;
|
|
@@ -200,14 +217,7 @@ function readTaskWords(input, ctx) {
|
|
|
200
217
|
let owner = null;
|
|
201
218
|
const nobody = [];
|
|
202
219
|
if (!skip.has("owner")) {
|
|
203
|
-
const byKey = (key) =>
|
|
204
|
-
const full = ctx.people.filter((p) => loose(p.name) === key);
|
|
205
|
-
if (full.length === 1) return full[0];
|
|
206
|
-
const first = ctx.people.filter((p) => loose(p.name.split(/\s+/)[0] ?? "") === key);
|
|
207
|
-
if (first.length === 1) return first[0];
|
|
208
|
-
const begins = ctx.people.filter((p) => loose(p.name).startsWith(key));
|
|
209
|
-
return key.length >= 3 && begins.length === 1 ? begins[0] : null;
|
|
210
|
-
};
|
|
220
|
+
const byKey = (key) => personForKey(key, ctx.people);
|
|
211
221
|
for (const m of text.matchAll(/(?:^|\s)@([\p{L}\p{N}._-]+)/gu)) {
|
|
212
222
|
const start = m.index + (m[0].length - m[0].trimStart().length);
|
|
213
223
|
const end = m.index + m[0].length;
|
|
@@ -307,4 +317,4 @@ function readTaskWords(input, ctx) {
|
|
|
307
317
|
};
|
|
308
318
|
}
|
|
309
319
|
|
|
310
|
-
export { dayFromWords, readTaskWords };
|
|
320
|
+
export { dayFromWords, looseName, personForKey, readTaskWords };
|