Sha256: 0b2af5393429cbbbbbba6a215e9fc30a039d04941d83d151d34ddd9433014bb5
Contents?: true
Size: 1.09 KB
Versions: 6
Compression:
Stored size: 1.09 KB
Contents
require "argy" require "pathname" module Geny # The top-level command file is evaulated in the context # of this class. class DSL # @private def initialize @helpers = [] @invoke = proc { warn "I don't know what to do!" } end # Define arguments and options that the command accepts. # The block is evaluated in the context of an {https://rubydoc.info/github/rzane/argy/Argy/Parser Argy::Parser}. def parse(&block) parser.instance_eval(&block) end # Define the behavior for when the command runs. The block is # evaluated in the context of a {Context::Invoke}. def invoke(&block) @invoke = block if block_given? @invoke end # Define helper methods. These methods are available within # the {#invoke} block and all templates. def helpers(&block) @helpers << Module.new(&block) if block_given? @helpers end # @private def parser @parser ||= Argy.new do |o| o.on "-h", "--help", "show this help and exit" do puts o.help exit end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
geny-2.1.1 | lib/geny/dsl.rb |
geny-2.1.0 | lib/geny/dsl.rb |
geny-2.0.0 | lib/geny/dsl.rb |
geny-1.0.1 | lib/geny/dsl.rb |
geny-1.0.0 | lib/geny/dsl.rb |
geny-0.1.0 | lib/geny/dsl.rb |