-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAct.hx
116 lines (109 loc) · 4.14 KB
/
Act.hx
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* SPDX-FileCopyrightText: © Sebastian Thomschke and contributors
* SPDX-FileContributor: Sebastian Thomschke
* SPDX-License-Identifier: MIT
* SPDX-ArtifactOfProjectHomePage: https://github.com/sebthom/more-clink-completions
*/
package more_clink_completions.completions;
import more_clink_completions.completions.Docker;
import sys.FileSystem;
import clink.util.Suggest;
import clink.util.LuaArray;
import clink.api.ArgMatcher;
import clink.api.Clink;
using clink.util.Strings;
/**
* Clink command line completions for "act". See https://github.com/nektos/act
*/
class Act {
public static function register() {
Clink.argMatcher("act").setDelayedInitializer(registerNow);
}
static function registerNow(parser:ArgMatcher, commandWord:String) {
parser
.addFlags(["-a", "--actor"], "")
.addFlag("--artifact-server-addr", "")
.addFlag("--artifact-server-path", "")
.addFlag("--artifact-server-port", "")
.addFlags(["-b", "--bind"])
.addFlag("--bug-report")
.addFlag("--container-architecture", "")
.addFlag("--container-cap-add", Docker.Capabilities.getConstructors())
.addFlag("--container-cap-drop", Docker.Capabilities.getConstructors())
.addFlag("--container-daemon-socket", "")
.addFlag("--container-options", "")
.addFlag("--defaultbranch", "")
.addFlag("--detect-event")
.addFlags(["-C", "--diretory"], Suggest.dirs)
.addFlags(["-n", "--dryrun"])
.addFlag("--env", "")
.addFlag("--env-file", Suggest.files)
.addFlags(["-e", "--eventpath"], Suggest.filesEndingWith(".json"))
.addFlag("--github-instance", "")
.addFlags(["-g", "--graph"])
.addFlags(["-h", "--help"])
.addFlag("--input", "")
.addFlag("--input-file", "")
.addFlag("--insecure-secrets")
.addFlags(["-j", "--jobs"], suggestJobIds)
.addFlag("--json")
.addFlags(["-l", "--list"])
.addFlag("--no-recurse")
.addFlag("--no-skip-checkout")
.addFlags(["-P", "--platform"], "")
.addFlag("--privileged")
.addFlags(["-p", "--pull"])
.addFlags(["-q", "--quiet"])
.addFlag("--rebuild")
.addFlag("--remote-name", "")
.addFlag("--replace-ghe-action-token-with-github-com", "")
.addFlag("--replace-ghe-action-with-github-com", "")
.addFlags(["-r", "--reuse"])
.addFlag("-rm")
.addFlags(["-s", "--secret"], "")
.addFlag("--secret-file", "")
.addFlag("--use-gitignore")
.addFlags(["-v", "--verbose"])
.addFlag("--version")
.addFlags(["-w", "--watch"])
.addFlags(["-W", "--workflows"], Suggest.filesEndingWith(".yml", ".yaml"))
.noFiles();
}
static function suggestJobIds():LuaArray<String> {
final jobIds = new LuaArray<String>();
for (file in FileSystem.readDirectory(".github/workflows")) {
if (file.endsWith(".yml") || file.endsWith(".yaml")) {
// poor man's YAML parsing
final content = sys.io.File.getContent('.github/workflows/$file');
if (content == null)
continue;
var isJobsSection = false;
var jobsIndention = -1;
for (line in @:nullSafety(Off) content.split("\n")) {
if (!isJobsSection) {
if (line.startsWith("jobs:")) {
isJobsSection = true;
}
continue;
}
if (line == "")
continue;
if (!line.hasMatch("^[%s#]")) {
isJobsSection = false;
continue;
}
final match = line.findMatch("^[%s]+([%w_-]+):");
if (match != null) {
if (jobsIndention == -1) {
jobsIndention = line.indexOf(match);
jobIds.add(match);
} else if (line.indexOf(match) == jobsIndention) {
jobIds.add(match);
}
}
}
}
}
return jobIds;
}
}