Module: Dry::CLI::Inline
- Extended by:
- Forwardable
- Defined in:
- lib/dry/cli/inline.rb
Overview
Inline Syntax (aka DSL) to implement one-file applications
‘dry/cli/inline` is not required by default and explicit requirement of this file means that it is expected of abusing global namespace with methods below
DSL consists of 5 methods: ‘desc`, `example`, `argument`, `option` — are similar to methods from Command class
‘run` accepts a block to execute
Constant Summary collapse
Instance Method Summary collapse
-
#run(arguments: ARGV, out: $stdout) ⇒ Object
The rule of thumb for implementation of run block is that for every argument from your CLI you need to specify that as an mandatory argument for a block.
Instance Method Details
#run(arguments: ARGV, out: $stdout) ⇒ Object
The rule of thumb for implementation of run block is that for every argument from your CLI you need to specify that as an mandatory argument for a block. Optional arguments have to have default value as ruby syntax expect them
63 64 65 66 67 68 69 70 |
# File 'lib/dry/cli/inline.rb', line 63 def run(arguments: ARGV, out: $stdout) command = AnonymousCommand command.define_method(:call) do |**args| yield(**args) end Dry.CLI(command).call(arguments: arguments, out: out) end |