-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathxc.ts
98 lines (97 loc) · 2.36 KB
/
xc.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* https://github.com/joerdav/xc
* xc - Simple, Convenient, Markdown-based task runner.
* v0.2.0
*/
const completionSpec: Fig.Spec = {
name: "xc",
description: "List tasks from an xc-compatible markdown file",
generateSpec: async (context, executeShellCommand) => {
const options: Fig.Option[] = [
{
name: ["-f", "-file"],
args: {
name: "path",
template: "filepaths",
},
description:
'Specify a markdown file that contains tasks (default: "README.md")',
},
{
name: ["-d", "-display"],
description: "Print the markdown code of a task rather than running it",
},
{
name: ["-H", "-heading"],
args: {
name: "heading",
suggestions: ["Tasks", "Usage", "Examples"],
},
description: 'Specify the heading for xc tasks (default: "Tasks")',
},
];
const { stdout } = await executeShellCommand({
command: "xc",
// eslint-disable-next-line @withfig/fig-linter/no-empty-array-values
args: [],
});
const subcommands: Fig.Subcommand[] = stdout
.trim()
.split("\n")
.map((line) =>
line
.trim()
.split(/^([^ ]* )/)
.map((s) => s.trim())
)
.map(([_, task, desc]) => ({
name: task,
description: desc,
options,
}));
return {
name: "xc",
subcommands,
};
},
options: [
{
name: ["-s", "-short"],
description: "List task names in a short format",
},
{
name: ["-h", "-help"],
description: "Print this help text",
},
{
name: ["-f", "-file"],
args: {
name: "path",
template: "filepaths",
},
description:
'Specify a markdown file that contains tasks (default: "README.md")',
},
{
name: ["-H", "-heading"],
args: {
name: "heading",
suggestions: ["Tasks", "Usage", "Examples"],
},
description: 'Specify the heading for xc tasks (default: "Tasks")',
},
{
name: ["-V", "-version"],
description: "Show xc version",
},
{
name: "-complete",
description: "Install shell completion for xc",
},
{
name: "-uncomplete",
description: "Uninstall shell completion for xc",
},
],
};
export default completionSpec;