mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
More minor changes
This commit is contained in:
parent
701a0e5054
commit
6b6cce486d
3 changed files with 78 additions and 17 deletions
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = {
|
||||
"system-new": {
|
||||
systemNew: {
|
||||
title: "Create a new system",
|
||||
summary: "Creates a new system if you do not already have one.",
|
||||
usage: [
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
"system-name": {type: "string", desc: "the name of the system to create", optional: true}
|
||||
}
|
||||
},
|
||||
"system-info": {
|
||||
systemInfo: {
|
||||
title: "Look up info about a system",
|
||||
summary: "Shows a system card, either your own or someone else's.",
|
||||
usage: [
|
||||
|
|
@ -20,5 +20,36 @@
|
|||
arguments: {
|
||||
"target": {type: "system", desc: "the system to look up"}
|
||||
}
|
||||
},
|
||||
systemName: {
|
||||
...systemSetterCommand("system name", "system name", "new-name", "Boxes of Foxes"),
|
||||
title: "Rename your system"
|
||||
},
|
||||
systemDesc: {
|
||||
...systemSetterCommand("system desc", "system description", "new-description", "Here is my cool new description!", {withRaw: true})
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
function systemSetterCommand(cmdPrefix, valueName, valueArg, exampleVal = "example-value", {argType = "string", withRaw = false} = {}) {
|
||||
var args = {};
|
||||
args[valueArg] = {type: argType, desc: `the new ${valueName}.`};
|
||||
return {
|
||||
title: `Change your ${valueName}`,
|
||||
summary: `Adds, changes, or removes your ${valueName}.`,
|
||||
usage: [
|
||||
{cmd: cmdPrefix, desc: `Shows your current ${valueName}.`},
|
||||
{cmd: `${cmdPrefix} \`${valueArg}\``, desc: `Sets your ${valueName}.`}
|
||||
],
|
||||
examples: [
|
||||
{cmd: cmdPrefix, desc: `Shows your current ${valueName}.`},
|
||||
{cmd: `${cmdPrefix} -clear`, desc: `Clears your ${valueName}.`},
|
||||
{cmd: `${cmdPrefix} \`${exampleVal}\``, desc: `Changes your ${valueName} to '${exampleVal}'`}
|
||||
],
|
||||
flags: {
|
||||
clear: {desc: `Clear the current ${valueName}.`},
|
||||
...(withRaw ? {raw: {desc: `Show the current ${valueName} in raw form, to copy/paste formatting more easily.`}} : {})
|
||||
},
|
||||
arguments: args
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
<slot></slot>
|
||||
|
||||
<h4>Syntax <small>(how the command is used)</small></h4>
|
||||
<CmdGroup>
|
||||
<Cmd v-for="usage in command.usage" :comment="usage.desc">
|
||||
<span v-for="part in parseUsage(usage)">
|
||||
|
|
@ -17,9 +18,28 @@
|
|||
</Cmd>
|
||||
</CmdGroup>
|
||||
|
||||
<h4>Arguments</h4>
|
||||
<div v-for="(arg, key) in command.arguments">
|
||||
<Arg>{{ key }}</Arg> (<strong v-if="arg.type === 'string'">text</strong><strong v-if="arg.type === 'system'">system ID</strong><span v-if="arg.optional">, <em>optional</em></span>) - {{ arg.desc }}.
|
||||
<h4 v-if="command.examples">Examples</h4>
|
||||
<CmdGroup v-if="command.examples">
|
||||
<Cmd v-for="example in command.examples" :comment="example.desc">
|
||||
<span v-for="part in parseUsage(example)">
|
||||
<span v-if="part.type === 'str'">{{ part.str }}</span>
|
||||
<span v-if="part.type === 'arg'"><Arg>{{ part.arg }}</Arg></span>
|
||||
</span>
|
||||
</Cmd>
|
||||
</CmdGroup>
|
||||
|
||||
<h4 v-if="command.arguments">Arguments <small>(fill in above)</small></h4>
|
||||
<div class="info-arg" v-for="(arg, key) in command.arguments">
|
||||
<Arg>{{ key }}</Arg>
|
||||
(<strong v-if="arg.type === 'string'">text</strong><strong v-if="arg.type === 'system'">system
|
||||
ID</strong><span v-if="arg.optional">, <em>optional</em></span>) - {{ arg.desc }}.
|
||||
</div>
|
||||
|
||||
<h4 v-if="command.flags">Flags <small>(all optional, starts with a hyphen, place anywhere in the
|
||||
command)</small></h4>
|
||||
<div class="info-flag" v-for="(flag, key) in command.flags">
|
||||
<Arg>-{{ key }}</Arg>
|
||||
- {{ flag.desc }}
|
||||
</div>
|
||||
|
||||
<!--table>
|
||||
|
|
@ -57,16 +77,20 @@
|
|||
parseUsage(usage) {
|
||||
if (usage.cmd) usage = usage.cmd;
|
||||
|
||||
const parts = usage.split(/\s/);
|
||||
const output = [];
|
||||
for (const part of parts) {
|
||||
const match = part.match(/`([\w\-]+)`/);
|
||||
if (match)
|
||||
output.push({type: "arg", arg: match[1]});
|
||||
else
|
||||
output.push({type: "str", str: part})
|
||||
const argRegex = /`([^`]+)`/g;
|
||||
const parts = [];
|
||||
let lastMatch = 0;
|
||||
for (const match of usage.matchAll(argRegex)) {
|
||||
if (match.index > 0)
|
||||
parts.push({type: "str", str: usage.substring(lastMatch, match.index)});
|
||||
parts.push({type: "arg", arg: match[1]});
|
||||
lastMatch = match.index + match[0].length;
|
||||
}
|
||||
return output;
|
||||
if (lastMatch < usage.length)
|
||||
parts.push({type: "str", str: usage.substring(lastMatch)});
|
||||
console.log("INPUT STRING:", usage);
|
||||
console.log("OUTPUT TOKENS:", parts);
|
||||
return parts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -88,4 +112,8 @@
|
|||
.command-info h4 {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.info-arg, .info-flag {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -21,8 +21,10 @@ When an argument asks for a **member ID**, you can either fill in a member's [5-
|
|||
You can use <CmdInline>s</CmdInline> instead of <CmdInline>system</CmdInline> as a short-hand.
|
||||
:::
|
||||
|
||||
<CommandInfo cmd="system-info"></CommandInfo>
|
||||
<CommandInfo cmd="system-new"></CommandInfo>
|
||||
<CommandInfo cmd="systemInfo"></CommandInfo>
|
||||
<CommandInfo cmd="systemNew"></CommandInfo>
|
||||
<CommandInfo cmd="systemName"></CommandInfo>
|
||||
<CommandInfo cmd="systemDesc"></CommandInfo>
|
||||
|
||||
## Member commands
|
||||
::: tip
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue