Module: Bloggit::Cmdline
- Defined in:
- lib/bloggit/commandline.rb
Class Attribute Summary collapse
-
.verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
Class Attribute Details
.verbose ⇒ Object
Returns the value of attribute verbose.
12 13 14 |
# File 'lib/bloggit/commandline.rb', line 12 def verbose @verbose end |
Class Method Details
.build(cmd, site = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/bloggit/commandline.rb', line 18 def build(cmd, site=nil) commands.each do |block| block.call(cmd, site) end end |
.commands ⇒ Object
8 9 10 |
# File 'lib/bloggit/commandline.rb', line 8 def commands @commands ||= [] end |
.execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bloggit/commandline.rb', line 24 def execute cmd = CmdParse::CommandParser.new( true, true ) Bloggit::Cmdline.verbose = false cmd.program_name = "bloggit" cmd.program_version = Bloggit::RELEASE_INFO cmd. = 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 |
.register(&block) ⇒ Object
14 15 16 |
# File 'lib/bloggit/commandline.rb', line 14 def register(&block) commands << block end |