Sha256: 4ac853539953251d1925fa3c451e28d86b698a99b78182d5837461246166174b
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
require 'fileutils' require 'cmdparse' module Bloggit module Cmdline class << self def commands @commands ||= [] end attr_accessor :verbose def register(&block) commands << block end def build(cmd, site=nil) commands.each do |block| block.call(cmd, site) end end def execute cmd = CmdParse::CommandParser.new( true, true ) Bloggit::Cmdline.verbose = false cmd.program_name = "bloggit" cmd.program_version = Bloggit::RELEASE_INFO cmd.options = CmdParse::OptionParserWrapper.new do |opt| opt.separator "Global options:" opt.on("--verbose", "Be verbose when outputting info") {|t| Bloggit::Cmdline.verbose = true } end puts "Loading commands from #{File.join( File.dirname(__FILE__), 'commands', '*.rb')} (#{Bloggit::Cmdline.verbose})" Dir[ File.join( File.dirname(__FILE__), 'commands', '*.rb') ].each do |command| require command end site = Dir.getwd.ends_with?('.blog') ? Bloggit::Site.from_file(Dir.getwd) : nil Cmdline.build( cmd, site ) cmd.add_command( CmdParse::HelpCommand.new ) cmd.add_command( CmdParse::VersionCommand.new ) cmd.parse end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bloggit-1.0.7 | lib/bloggit/commandline.rb |