@coderich/sandman 0.0.11 → 0.0.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coderich/sandman",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "main": "index.js",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,7 +26,8 @@ exports.createInterface = (cli, configClient) => {
26
26
  const lastArg = args.at(-1) || '';
27
27
  const lastPaths = lastArg.split('.');
28
28
  const lastPath = lastPaths.at(-1); // current typing
29
- const previousPath = lastPaths.slice(0, -1).join('.');
29
+ const previousPaths = lastPaths.slice(0, -1);
30
+ const previousPath = previousPaths.join('.');
30
31
 
31
32
  // Specific request.data selector
32
33
  if (lastArg.startsWith('.')) {
@@ -40,9 +41,14 @@ exports.createInterface = (cli, configClient) => {
40
41
  const requestKeys = flatKeys.map(k => k.substring(0, Math.max(k.indexOf('.request'), 0))).filter(Boolean);
41
42
 
42
43
  const candidates = Array.from(new Set(requestKeys
43
- .filter(requestKey => requestKey.toLowerCase().startsWith(previousPath.toLowerCase()))
44
- .filter(requestKey => requestKey.split('.').slice(lastPaths.length - 1).join('.').toLowerCase().includes(lastPath.toLowerCase()))
45
- // .concat(Object.keys(cli).filter(key => key.toLowerCase().startsWith(cmd.toLowerCase())))
44
+ .filter((requestKey) => {
45
+ const requestPaths = requestKey.split('.').map(rp => rp.toLowerCase());
46
+ return previousPaths.every(path => requestPaths.includes(path.toLowerCase()));
47
+ })
48
+ .filter((requestKey) => {
49
+ const requestPaths = requestKey.split('.');
50
+ return requestPaths.slice(lastPaths.length - 1).join('.').toLowerCase().includes(lastPath.toLowerCase());
51
+ })
46
52
  ));
47
53
 
48
54
  if (captureInfo.captureCandidates && lastArg) { captureInfo.candidates = candidates; captureInfo.line = line; captureInfo.lastArg = lastArg; captureInfo.candidateIndex = -1; }
package/src/Sandman.js CHANGED
@@ -75,7 +75,7 @@ module.exports = class Sandman extends EventEmitter {
75
75
  const child = spawn(path, [filePath], { detached: true, stdio: 'ignore' });
76
76
  child.unref();
77
77
  },
78
- show: key => ({
78
+ view: key => ({
79
79
  $: this.#configClient.raw(key),
80
80
  [key]: this.#configClient.get(key),
81
81
  }),