2023-08-09 15:44:57 +00:00
|
|
|
import std.stdio;
|
2023-08-09 17:57:38 +00:00
|
|
|
import std.getopt;
|
2023-08-09 15:44:57 +00:00
|
|
|
|
2023-08-09 17:57:38 +00:00
|
|
|
import prompt.ps1;
|
2023-08-09 19:05:26 +00:00
|
|
|
import prompt.preexec;
|
|
|
|
import style.color;
|
2023-08-09 17:57:38 +00:00
|
|
|
|
|
|
|
struct Opt {
|
|
|
|
bool ps1;
|
|
|
|
bool rps1;
|
2023-08-09 19:05:26 +00:00
|
|
|
bool preexec;
|
2023-08-09 17:57:38 +00:00
|
|
|
|
|
|
|
int col;
|
|
|
|
int row;
|
|
|
|
}
|
|
|
|
|
|
|
|
void main(string[] argv) {
|
|
|
|
Opt opts;
|
|
|
|
|
|
|
|
GetoptResult args = getopt(
|
|
|
|
argv,
|
|
|
|
std.getopt.config.bundling,
|
|
|
|
"ps1|p", "print PS1", &opts.ps1,
|
|
|
|
"rps1|r", "print RPS1", &opts.rps1,
|
2023-08-09 19:05:26 +00:00
|
|
|
"preexec|x", "print preexec", &opts.preexec,
|
|
|
|
|
|
|
|
std.getopt.config.required,
|
2023-08-09 17:57:38 +00:00
|
|
|
"col", "terminal width", &opts.col,
|
2023-08-09 19:05:26 +00:00
|
|
|
std.getopt.config.required,
|
2023-08-09 17:57:38 +00:00
|
|
|
"row", "terminal height", &opts.row,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (args.helpWanted) {
|
|
|
|
defaultGetoptPrinter("prim", args.options);
|
|
|
|
}
|
|
|
|
|
2023-08-09 19:05:26 +00:00
|
|
|
if (opts.ps1) {
|
|
|
|
ps1(opts.col).setColor(Color.black).write();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opts.preexec) {
|
|
|
|
preexec(opts.col).setColor(Color.black).write();
|
2023-08-09 17:57:38 +00:00
|
|
|
}
|
|
|
|
|
2023-08-09 19:05:26 +00:00
|
|
|
write(setColor("", Color.reset));
|
2023-08-09 15:44:57 +00:00
|
|
|
}
|