Custom args parser for Seyfert.
bun add sslp
or pnpm...
pnpm add sslp
Integrating SSLP into your Seyfert client is straightforward:
import { Client } from "seyfert";
import { ArgsParser } from "sslp"
const parser = new ArgsParser();
const seyfertClient = new Client({
commands: {
argsParser: (content, command) => parser.runParser(content, command)
}
});
// That's it! Now you can use Seyfert with your new upgraded args parser!
SSLP allows you to configure various aspects of argument parsing, including:
- Prefixes: Define custom prefixes for options and flags.
- Separators: Specify separators between option names and values.
- Quotes: Support for different quote styles to encapsulate values.
Quote patterns enable you to define complex quote styles using regular expressions or simple strings. These patterns need to be activated for use:
import { ArgsParser, ParserConfig } from 'sslp';
// Define quote patterns using regular expressions
const customQuotePatterns = [
[/```(ts|js)/, "```"], // Matches ```ts and ```js
["```", "```"], // Matches simple ``` quotes
];
// Apply quote patterns to a command class
@ParserConfig({ quotes: customQuotePatterns })
class MyCommand extends Command {
// Command implementation
}
Use the @ParserConfig
decorator to set parser configuration directly on command classes:
import { ParserConfig } from 'sslp';
@ParserConfig({ prefixes: ['--'], separators: ['='] })
class MyCommand extends Command {
// Command implementation
}