Skip to content

Commit

Permalink
Basic CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo committed Dec 4, 2009
1 parent 56cbf42 commit 2309f00
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bin/jira
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby

require 'rubygems'

# require 'jira'
require File.dirname(__FILE__) + '/../lib/jira'

Jira::CLI.execute
41 changes: 41 additions & 0 deletions lib/jira/cli.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'optparse'

module Jira
class CLI
attr_reader :action, :options, :args

def self.execute
parse(ARGV).execute!
end

def self.parse(args)
cli = new(args)
cli.parse_options!
cli.load_global_options
cli
end

def initialize(args)
@args = args.dup
end

def execute!
case action
when 'list':
handle_ticket_list
else
puts 'not a command'
end
end

def parse_options!
if args.empty?
warn "Please specify at least one action to execute."
puts " list"
exit
end

@action = args.first
end
end
end

0 comments on commit 2309f00

Please sign in to comment.