Sha256: cbaa2f3d95809a70cf75e95c9dcfd06add3c6c9bce91bc65a2dd2b0b7797a6d1
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
#! /usr/bin/env ruby # frozen_string_literal: true # 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clamp-1.3.2 | examples/gitdown |
clamp-1.3.1 | examples/gitdown |
clamp-1.3.0 | examples/gitdown |