Sha256: 07371cebcd9431d9cd5e8ea09b55092b65eef657d921558c447207a5a5181846

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.join(File.expand_path(__FILE__), "..", "..", "lib", "convoy"))
require File.join(File.expand_path(__FILE__), "..", "commands", "example_command")

Convoy::App.create do |app|
    app.options do |opts|
        opts.opt :flag1, "Flag 1", :short => '-f', :long => '--flag1', :type => :boolean
        opts.opt :flag2, "Flag 2", :short => :none, :long => '--flag2', :type => :boolean, :default => true
        opts.opt :option1, "Option1", :short => '-o', :long => '--option1', :type => :string
        opts.opt :option2, "Option2", :short => :none, :long => '--option2', :type => :string, :multi => true
        opts.opt :option3, "Option3", :short => :none, :long => '--option3', :type => :string
        opts.opt :option4, "Option4", :short => :none, :long => '--option4', :type => :string

        opts.dependency :option1, :on => :flag1
        opts.dependency :option2, :on => [:flag1, :option1]
        opts.dependency :option3, :on => { :option1 => 'foo' }
        #opts.dependency :option4, :on => [{:flag1 => false}, :option1] #This will get you into big trouble as it can never be fulfilled
        opts.dependency :option4, :on => [{ :flag2 => false }, :option1]
    end

    app.action do |options, arguments|
        Convoy::ExampleCommand.new(options, arguments).execute
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
convoy-1.3.2 examples/basic_depends_on
convoy-1.2.0 examples/basic_depends_on