Created and implemented status search flag for search command
This commit is contained in:
parent
d2dc69f35d
commit
77e5f429c5
1 changed files with 23 additions and 6 deletions
|
@ -120,6 +120,7 @@ type MemberSearchParams = {
|
||||||
sort?: string;
|
sort?: string;
|
||||||
"case-sensitive"?: boolean;
|
"case-sensitive"?: boolean;
|
||||||
regex?: boolean;
|
regex?: boolean;
|
||||||
|
"status-search"?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SearchError extends Error {}
|
class SearchError extends Error {}
|
||||||
|
@ -381,6 +382,15 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
throw new SearchError("Unsafe/too complex regex (star depth is limited to 1)");
|
throw new SearchError("Unsafe/too complex regex (star depth is limited to 1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args["status-search"]) {
|
||||||
|
matchingMembers = matchingMembers.filter(member => {
|
||||||
|
if (member.game) {
|
||||||
|
if (member.game.name && member.game.name.match(queryRegex)) return true;
|
||||||
|
if (member.game.state && member.game.state.match(queryRegex)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
matchingMembers = matchingMembers.filter(member => {
|
matchingMembers = matchingMembers.filter(member => {
|
||||||
if (member.nick && member.nick.match(queryRegex)) return true;
|
if (member.nick && member.nick.match(queryRegex)) return true;
|
||||||
|
|
||||||
|
@ -390,6 +400,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const [, sortDir, sortBy] = args.sort ? args.sort.match(/^(-?)(.*)$/) : [null, "ASC", "name"];
|
const [, sortDir, sortBy] = args.sort ? args.sort.match(/^(-?)(.*)$/) : [null, "ASC", "name"];
|
||||||
const realSortDir = sortDir === "-" ? "DESC" : "ASC";
|
const realSortDir = sortDir === "-" ? "DESC" : "ASC";
|
||||||
|
@ -469,6 +480,11 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
shortcut: "re",
|
shortcut: "re",
|
||||||
isSwitch: true,
|
isSwitch: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "status-search",
|
||||||
|
shortcut: "ss",
|
||||||
|
isSwitch: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
extra: {
|
extra: {
|
||||||
info: <CommandInfo>{
|
info: <CommandInfo>{
|
||||||
|
@ -500,6 +516,7 @@ export class UtilityPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
export?: boolean;
|
export?: boolean;
|
||||||
ids?: boolean;
|
ids?: boolean;
|
||||||
regex?: boolean;
|
regex?: boolean;
|
||||||
|
"status-search"?: boolean;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const formatSearchResultList = (members: Member[]): string => {
|
const formatSearchResultList = (members: Member[]): string => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue