-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.d
143 lines (111 loc) · 3.48 KB
/
options.d
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
module options;
import std.getopt;
import dubproxy.options : DubProxyOptions;
@safe:
struct DubProxyCliOptions {
import dubproxy.git : TagKind;
DubProxyOptions libOptions;
bool verbose;
bool mirrorCodeDlang;
string mirrorFilename = "code.json";
string[] packages;
string proxyFile = "dubproxy.json";
string packageFolder = getDefaultPackageFolder();
string gitFolder = getDefaultPackageFolder();
bool dummyDubProxy;
string dummyDubProxyPath = ".";
string showTagsPath;
TagKind tagKind = TagKind.all;
bool cloneAll;
bool cloneAllNoTerminal;
bool genAllTags;
}
private DubProxyCliOptions __options;
ref DubProxyCliOptions writeAbleOptions() {
return __options;
}
@property ref const(DubProxyCliOptions) options() {
return __options;
}
string getDefaultPackageFolder() pure {
version(Posix) {
return "~/.dub/packages/";
} else version(Windows) {
return `%APPDATA%\dub\packages\`;
} else {
static assert(false, "Unsupported platform");
}
}
string getDefaultGitFolder() pure {
version(Posix) {
return "~/.dub/DubProxyGits/";
} else version(Windows) {
return `%APPDATA%\dub\DubProxyGits\`;
} else {
static assert(false, "Unsupported platform");
}
}
GetoptResult parseOptions(ref string[] args) {
auto helpInformation = getopt(args,
"m|mirror",
"Get a list of packages currently available on code.dlang.org"
~ "\n\t\t\tand store a file specified in \"n|mirrorFileName\"",
&writeAbleOptions().mirrorCodeDlang,
"n|mirrorFileName",
"The filename where to store the packages available on code.dlang.org",
&writeAbleOptions().mirrorFilename,
"d|dubPath",
"The path to the dub executable",
&writeAbleOptions().libOptions.pathToDub,
"p|gitPath",
"The path to the git executable",
&writeAbleOptions().libOptions.pathToGit,
"f|gitFolder",
"The path where the gits get cloned to",
&writeAbleOptions().gitFolder,
"overrideGit",
"Allow to override the git folder of cloned packages",
&writeAbleOptions().libOptions.ovrGF,
"overrideTree",
"Allow to override the git worktree folder of cloned package version",
&writeAbleOptions().libOptions.ovrWTF,
"g|get",
"Get a precific package. \"-g dub\" will fetch dub and create"
~ "\n\t\t\tfolders for all version tags for dub. \"-g dub:1.1.0\" will "
~ "\n\t\t\ttry to get dub and create a package for v1.1.0. "
~ "\n\t\t\t\"g dub:~master\" will try get dub and create a package for "
~ "\n\t\t\t~master",
&writeAbleOptions().packages,
"i|proxyFile",
"The filename of the dubproxy file to search packages in",
&writeAbleOptions().proxyFile,
"o|packagesFolder",
"The path where packages should be stored",
&writeAbleOptions().packageFolder,
"dummy",
"Generate a empty dubproxy.json file",
&writeAbleOptions().dummyDubProxy,
"dummyPath",
"Path to the folder where to create the dummy dubproxy.json file",
&writeAbleOptions().dummyDubProxyPath,
"t|tags",
"Show tags for passed dirpath or url",
&writeAbleOptions().showTagsPath,
"k|tagsKind",
"Limit tags to a specific kind of tags",
&writeAbleOptions().tagKind,
"a|cloneAll",
"Clone or fetch all packages provided in \"i|input\"",
&writeAbleOptions().cloneAll,
"u|noUserInteraction",
"Run git without user interaction",
&writeAbleOptions().libOptions.noUserInteraction,
"v|verbose",
"Get some more output of what is going on",
&writeAbleOptions().verbose,
"genAllTags",
"Generate tags for all the repos in gitFolder listed in proxyFile",
&writeAbleOptions().genAllTags,
);
return helpInformation;
}