A new way to register Command

This commit is contained in:
Folyd 2020-05-18 22:59:36 +08:00
parent 8ba8902caa
commit 45e1edbf82
2 changed files with 5 additions and 3 deletions

View file

@ -5,8 +5,9 @@ class HelpCommand extends Command {
onExecute() {
const value = ([
`Prefix ${c.match(":")} to execute command (:book, :yet, :stable etc)`,
`Prefix ${c.match(":")} to execute command (:book, :yet, :stable, etc)`,
`Prefix ${c.match("!")} to search crates, prefix ${c.match("!!")} to search crates's docs url`,
`Prefix ${c.match("~")} to search external crate's docs`,
`Prefix ${c.match("@crate")} (${c.dim("e.g. @tokio")}) to search that crate's doc exclusively`,
`Prefix ${c.match("#")} to search builtin attributes`,
`Prefix ${c.match("%")} to search Rust official book chapters`,

View file

@ -5,14 +5,15 @@ const bookSearcher = new BookSearch(booksIndex);
const lintSearcher = new LintSearch(lintsIndex);
const stdSearcher = new StdSearch(searchIndex);
const crateDocSearchManager = new CrateDocSearchManager();
const commandManager = new CommandManager([
const commandManager = new CommandManager(
new HelpCommand(),
new BookCommand(),
new YetCommand(),
new StableCommand(),
new ToolCommand(),
new LabelCommand(labelsIndex),
]);
new HistoryCommand(),
);
const defaultSuggestion = `Search std ${c.match("docs")}, external ${c.match("docs")} (@), ${c.match("crates")} (!), ${c.match("attributes")} (#), ${c.match("books")} (%), clippy ${c.match("lints")} (>), and ${c.match("error codes")}, etc in your address bar instantly!`;
const omnibox = new Omnibox(defaultSuggestion, c.omniboxPageSize());