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 20:01:15 +00:00
|
|
|
import prim.opt;
|
|
|
|
|
2023-08-09 17:57:38 +00:00
|
|
|
import prompt.ps1;
|
2023-08-09 20:01:15 +00:00
|
|
|
import prompt.rps1;
|
2023-08-09 19:05:26 +00:00
|
|
|
import prompt.preexec;
|
2023-08-09 17:57:38 +00:00
|
|
|
|
2023-08-09 20:01:15 +00:00
|
|
|
import style;
|
|
|
|
import style.color;
|
2023-08-09 17:57:38 +00:00
|
|
|
|
|
|
|
void main(string[] argv) {
|
2023-08-09 20:01:15 +00:00
|
|
|
Opts opts;
|
2023-08-09 17:57:38 +00:00
|
|
|
|
|
|
|
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 20:01:15 +00:00
|
|
|
|
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,
|
2023-08-09 20:01:15 +00:00
|
|
|
|
|
|
|
std.getopt.config.required,
|
|
|
|
"status", "previous command exit code", &opts.status,
|
2023-08-09 17:57:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if (args.helpWanted) {
|
|
|
|
defaultGetoptPrinter("prim", args.options);
|
|
|
|
}
|
|
|
|
|
2023-08-09 20:01:15 +00:00
|
|
|
dorun(opts);
|
|
|
|
}
|
|
|
|
|
|
|
|
void dorun(Opts opts) {
|
2023-08-09 19:05:26 +00:00
|
|
|
if (opts.ps1) {
|
2023-08-09 20:01:15 +00:00
|
|
|
ps1(opts).write();
|
2023-08-09 19:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (opts.preexec) {
|
2023-08-09 20:01:15 +00:00
|
|
|
preexec(opts.col).write();
|
2023-08-09 17:57:38 +00:00
|
|
|
}
|
|
|
|
|
2023-08-09 20:01:15 +00:00
|
|
|
if (opts.rps1) {
|
|
|
|
rps1(opts).write();
|
|
|
|
}
|
2023-08-09 15:44:57 +00:00
|
|
|
}
|