Skip to content

Commit

Permalink
Removing subcommand/pickled_optparse combination in favor of cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdsumsion committed Jan 25, 2012
1 parent 06be618 commit 772f913
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 43 deletions.
3 changes: 1 addition & 2 deletions git-ged.gemspec
Expand Up @@ -23,8 +23,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w[README.md LICENSE LICENSE.grit TODO layout.txt] s.extra_rdoc_files = %w[README.md LICENSE LICENSE.grit TODO layout.txt]


s.add_dependency('grit', "~> 2.4.1") s.add_dependency('grit', "~> 2.4.1")
s.add_dependency('pickled_optparse', "~> 0.1.1") s.add_dependency('cli', "~> 1.1.0")
s.add_dependency('subcommand', "~> 1.0.6")


s.add_development_dependency('mocha') s.add_development_dependency('mocha')


Expand Down
2 changes: 1 addition & 1 deletion lib/git-ged.rb
Expand Up @@ -23,7 +23,7 @@
# internal support classes # internal support classes


module GitGed module GitGed
VERSION = '0.0.3' VERSION = '0.0.4'


class << self class << self


Expand Down
78 changes: 38 additions & 40 deletions lib/git-ged/cli.rb
@@ -1,52 +1,50 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby


require 'git-ged' require 'git-ged'
require 'picled_optparse'
require 'subcommand'


module GitGed module GitGed
class CLI class CLI


include Subcommands # include Subcommands

#
# patch until subcommand 1.0.7 comes out # # patch until subcommand 1.0.7 comes out
attr_accessor :appname # attr_accessor :appname
def print_actions # def print_actions
super.sub(/See '.* help COMMAND'/, "See '#{appname} help COMMAND'") # super.sub(/See '.* help COMMAND'/, "See '#{appname} help COMMAND'")
end # end


def initialize # def initialize
@options = {} # @options = {}

#
self.appname = "git ged" # self.appname = "git ged"
global_options do |opts| # global_options do |opts|
opts.banner = "Usage: #{appname} [options] [subcommand [options]]" # opts.banner = "Usage: #{appname} [options] [subcommand [options]]"
opts.separator "" # opts.separator ""
opts.separator "Global options are:" # opts.separator "Global options are:"
opts.on("-v", "--[no-]verbose", "Show git-ged & grit debug") do |v| # opts.on("-v", "--[no-]verbose", "Show git-ged & grit debug") do |v|
GitGed.debug = v # GitGed.debug = v
end # end
end # end
add_help_option # add_help_option

#
command :init do |opts| # command :init do |opts|
opts.banner = "Usage: #{appname} init -m msg [repo]" # opts.banner = "Usage: #{appname} init -m msg [repo]"
opts.description = "Initializes a new git-ged repo" # opts.description = "Initializes a new git-ged repo"
opts.separator "" # opts.separator ""
opts.separator "Options:" # opts.separator "Options:"
opts.on "-m INTENT", "--message INTENT" do |intent| # opts.on "-m INTENT", "--message INTENT" do |intent|
@options[:intent] = intent # @options[:intent] = intent
end # end
end # end
end # end


def run def run
cmd = opt_parse() # cmd = opt_parse()
if cmd # if cmd
Repo.new.send cmd, ARGV, @options # Repo.new.send cmd, ARGV, @options
else # else
puts global_options { |opts| opts } # puts global_options { |opts| opts }
end # end
end end


end end
Expand Down

0 comments on commit 772f913

Please sign in to comment.