-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
79 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const generator: Fig.Generator = { | ||
script(args) { | ||
console.log(args); | ||
return [ | ||
"moonx", | ||
"_moonx_list", | ||
...args.filter( | ||
(arg) => !arg.startsWith("-") && arg.length && "moonx" !== arg, | ||
), | ||
]; | ||
}, | ||
trigger: "moonx", | ||
postProcess(out) { | ||
console.log("here"); | ||
const lines = out.split("\n"); | ||
return lines.map((line) => { | ||
return { | ||
name: line, | ||
}; | ||
}); | ||
}, | ||
}; | ||
|
||
const completionSpec: Fig.Spec = { | ||
name: "moonx", | ||
args: { | ||
isVariadic: true, | ||
generators: generator, | ||
}, | ||
}; | ||
export default completionSpec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export function exec( | ||
command: string, | ||
wss: Array<string>, | ||
commands: Map<string, string[]>, | ||
) { | ||
const wokspaces = commands.get(command); | ||
if (!wokspaces) { | ||
throw new Error(`task ${command} does not exist`); | ||
} | ||
if (!wss.length) { | ||
return [`:${command}`]; | ||
} | ||
return wss | ||
.filter((ws) => wokspaces.includes(ws)) | ||
.map((ws) => `${ws}:${command}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export function list( | ||
[command, ...wss]: Array<string>, | ||
commands: Map<string, string[]>, | ||
) { | ||
if (!commands.has(command) && wss.length) { | ||
console.log(`task ${command} does not exist`); | ||
return []; | ||
} | ||
if (!commands.has(command)) { | ||
return Array.from(commands.keys()); | ||
} | ||
const workspaces = commands.get(command)!; | ||
if (!wss.length) { | ||
return workspaces; | ||
} | ||
return wss.filter((ws) => workspaces.includes(ws)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters