
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
lita-keyword-arguments
Advanced tools
lita-keyword-arguments is an extension for Lita that extracts keyword arguments from messages in the style of command line flags.
Add lita-keyword-arguments to your Lita plugin's gemspec:
spec.add_runtime_dependency "lita-keyword-arguments"
Require it in your Lita plugin's source:
require "lita-keyword-arguments"
Define keyword arguments for a route using the kwargs
option. The value should be a hash, mapping keywords to a hash detailing the rules about that keyword.
When the route matches, the response object passed to the handler method will have the :kwargs
key in its extensions
attribute populated with the parsed keyword argument values.
Example:
class MyHandler < Lita::Handler
route(
/^my_command/,
:callback
command: true,
kwargs: {
foo: {},
bar: {
short: "b",
default: "unset"
},
verbose: {
short: "v",
boolean: true
}
}
)
def callback(response)
# response.extensions[:kwargs] will be populated with a hash of keywords and their values.
end
end
The above :kwargs
hash would make lita-keyword-arguments recognize the following in messages:
[--foo VALUE] [-b | --bar VALUE] [-v | --verbose | --no-verbose]
The :bar
keyword be set to the string "unset" if no value was provided in the message.
The possible keys for each keyword argument's specification are:
:short
- A single letter to use for the short flag. Invoked with a single preceeding dash. For example: "-f".:boolean
- The kwarg represents a boolean and does not have an argument. Set to true by providing the flag. Set to false by providing the long version of the flag, prefixing the keyword with "no-". For example: "--no-verbose".:default
- A default value to give the keyword argument if the flag is not provided in the message.The long flag (e.g. --foo) is automatically created from the key.
Example messages and their resulting hashes:
# Lita: my_command -b hello
{ bar: "hello" }
# Lita: my_command --foo baz
{ foo: "baz", bar: "unset" }
# Lita: my_command -v
{ bar: "unset", verbose: true }
# Lita: my_command --no-verbose
{ bar: "unset", verbose: false }
FAQs
Unknown package
We found that lita-keyword-arguments demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.