Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Map options to a class. Simply create a class with the appropriate annotations, and have options automatically map to functions and parameters.
Example:
class MyApp < Thor # [1]
map "-L" => :list # [2]
desc "install APP_NAME", "install one of the available apps" # [3]
method_options :force => :boolean, :alias => :optional # [4]
def install(name)
user_alias = options[:alias]
if options.force?
# do something
end
# ... other code ...
end
desc "list [SEARCH]", "list all of the available apps, limited by SEARCH"
def list(search = "")
# list everything
end
end
Thor automatically maps commands as such:
app install myname --force
That gets converted to:
MyApp.new.install("myname")
# with {'force' => true} as options hash
--
and -
params.
In this case, a --force
and a -f
option is added.method_options
:boolean
true or false
:boolean
, but fall back to given boolean as default value:required
:optional
:numeric
:optional
, but fall back to the given object as default valueIn case of unsatisfied requirements, Thor::Options::Error
is raised.
Examples of option parsing:
# let's say this is how we defined options for a method:
method_options(:force => :boolean, :retries => :numeric)
# here is how the following command-line invocations would be parsed:
command -f --retries 5 # => {'force' => true, 'retries' => 5}
command --force -r=5 # => {'force' => true, 'retries' => 5}
command -fr 5 # => {'force' => true, 'retries' => 5}
command --retries=5 # => {'retries' => 5}
command -r5 # => {'retries' => 5}
FAQs
Unknown package
We found that botanicus-thor 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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.