Sha256: c479f85558c2a68a4fbe7a65d6ad0c532e69fb2e5c63869fd40bb8c17e9c93fd

Contents?: true

Size: 1.28 KB

Versions: 83

Compression:

Stored size: 1.28 KB

Contents

#! /usr/bin/env ruby

# Demonstrate how subcommands can be declared as classes

require "clamp"

module GitDown

  class AbstractCommand < Clamp::Command

    option ["-v", "--verbose"], :flag, "be verbose"

    option "--version", :flag, "show version" do
      puts "GitDown-0.0.0a"
      exit(0)
    end

    def say(message)
      message = message.upcase if verbose?
      puts message
    end

  end

  class CloneCommand < AbstractCommand

    parameter "REPOSITORY", "repository to clone"
    parameter "[DIR]", "working directory", :default => "."

    def execute
      say "cloning to #{dir}"
    end

  end

  class PullCommand < AbstractCommand

    option "--[no-]commit", :flag, "Perform the merge and commit the result."

    def execute
      say "pulling"
    end

  end

  class StatusCommand < AbstractCommand

    option ["-s", "--short"], :flag, "Give the output in the short-format."

    def execute
      if short?
        say "good"
      else
        say "it's all good ..."
      end
    end

  end

  class MainCommand < AbstractCommand

    subcommand "clone", "Clone a remote repository.", CloneCommand
    subcommand "pull", "Fetch and merge updates.", PullCommand
    subcommand "status", "Display status of local repository.", StatusCommand

  end

end

GitDown::MainCommand.run

Version data entries

83 entries across 79 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/clamp-0.6.5/examples/gitdown