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;
|
|
|
|
|
|
|
|
struct Opt {
|
|
|
|
bool ps1;
|
|
|
|
bool rps1;
|
|
|
|
|
|
|
|
int col;
|
|
|
|
int row;
|
|
|
|
}
|
|
|
|
|
|
|
|
void validate(Opt opts) {
|
|
|
|
if (!opts.col || !opts.row)
|
|
|
|
throw new Exception("--col and --row required");
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
"col", "terminal width", &opts.col,
|
|
|
|
"row", "terminal height", &opts.row,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (args.helpWanted) {
|
|
|
|
defaultGetoptPrinter("prim", args.options);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
validate(opts);
|
|
|
|
} catch (Exception e) {
|
|
|
|
defaultGetoptPrinter(e.msg ~ "\n", args.options);
|
|
|
|
}
|
|
|
|
|
|
|
|
ps1(opts.col).write();
|
2023-08-09 15:44:57 +00:00
|
|
|
}
|