You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
990 B
38 lines
990 B
import {message, error, log, debug, Color, _} from "./util.js";
|
|
import search from "./search.js";
|
|
|
|
class MPT {
|
|
options;
|
|
subcommand;
|
|
|
|
constructor(options) {
|
|
this.options = options;
|
|
|
|
const subcommand = options._[0];
|
|
const parameters = options._.slice(1);
|
|
switch(subcommand) {
|
|
case "search":
|
|
this.search(parameters, options.v === "" ? null : options.v);
|
|
break;
|
|
default:
|
|
message(`unknown command '${subcommand}'`);
|
|
break;
|
|
}
|
|
}
|
|
|
|
async search(parameters, version = null) {
|
|
if (!parameters)
|
|
error(" You must give at least one search pattern");
|
|
const results = await search(parameters.join(" "), version);
|
|
for(const result of results) {
|
|
log(`${_(Color.GREEN)}${result.name} ${_(Color.MAGENTA)}[${result.id}]${_(Color.NONE)}`);
|
|
log(` ${result.description}\n`);
|
|
log(` ${_(Color.CYAN)}latest files:`);
|
|
for (const file of result.files)
|
|
log(` ${_(Color.CYAN)}- ${_(Color.YELLOW)}${file}${_(Color.NONE)}`);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export default MPT; |