mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-19 20:16:04 +08:00
added command line aliases
This commit is contained in:
parent
cabbcc22f3
commit
b4b036eb2f
1 changed files with 16 additions and 4 deletions
|
@ -29,9 +29,10 @@ function addChildCommands(
|
|||
try {
|
||||
commandItem.exec();
|
||||
const currentCommandsIndex = currentCommands.length - 1;
|
||||
currentCommands[currentCommandsIndex].list.forEach((cmd) =>
|
||||
addChildCommands(unifiedCommands, cmd, commandItemDisplay)
|
||||
);
|
||||
currentCommands[currentCommandsIndex].list.forEach((cmd) => {
|
||||
if (cmd.alias === undefined) cmd.alias = commandItem.alias;
|
||||
addChildCommands(unifiedCommands, cmd, commandItemDisplay);
|
||||
});
|
||||
currentCommands.pop();
|
||||
} catch (e) {}
|
||||
} else {
|
||||
|
@ -110,6 +111,7 @@ let commands = {
|
|||
{
|
||||
id: "changeWordCount",
|
||||
display: "Change word count...",
|
||||
alias: "words",
|
||||
subgroup: true,
|
||||
exec: () => {
|
||||
currentCommands.push(commandsWordCount);
|
||||
|
@ -119,6 +121,7 @@ let commands = {
|
|||
{
|
||||
id: "changeQuoteLength",
|
||||
display: "Change quote length...",
|
||||
alias: "quotes",
|
||||
subgroup: true,
|
||||
exec: () => {
|
||||
currentCommands.push(commandsQuoteLengthConfig);
|
||||
|
@ -573,6 +576,7 @@ let commands = {
|
|||
{
|
||||
id: "viewTypingPage",
|
||||
display: "View Typing Page",
|
||||
alias: "start begin type test",
|
||||
exec: () => $("#top #menu .icon-button.view-start").click(),
|
||||
},
|
||||
{
|
||||
|
@ -593,6 +597,7 @@ let commands = {
|
|||
{
|
||||
id: "viewAccount",
|
||||
display: "View Account Page",
|
||||
alias: "stats",
|
||||
exec: () =>
|
||||
$("#top #menu .icon-button.view-account").hasClass("hidden")
|
||||
? $("#top #menu .icon-button.view-login").click()
|
||||
|
@ -2191,7 +2196,14 @@ function updateSuggestedCommands() {
|
|||
let escaped = obj2.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
||||
let re = new RegExp("\\b" + escaped, "g");
|
||||
let res = obj.display.toLowerCase().match(re);
|
||||
if (res != null && res.length > 0) {
|
||||
let res2 = null;
|
||||
if (obj.alias !== undefined) {
|
||||
res2 = obj.alias.toLowerCase().match(re);
|
||||
}
|
||||
if (
|
||||
(res != null && res.length > 0) ||
|
||||
(res2 != null && res2.length > 0)
|
||||
) {
|
||||
foundcount++;
|
||||
} else {
|
||||
foundcount--;
|
||||
|
|
Loading…
Add table
Reference in a new issue