Class: Filament::Application
- Inherits:
-
Object
- Object
- Filament::Application
- Defined in:
- lib/filament.rb
Constant Summary collapse
- @@plugins =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #parse(args) ⇒ Object
- #run(args) ⇒ Object
- #subcommand(name, short_desc, has_subcommands = false, &block) ⇒ Object
- #workspace_path ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/filament.rb', line 92 def initialize @cmd = CmdParse::CommandParser.new(true) @cmd.program_name = "filament" @cmd.program_version = [0, 4, 0] @cmd.add_command(CmdParse::HelpCommand.new) @cmd.add_command(CmdParse::VersionCommand.new) @cmd. = CmdParse::OptionParserWrapper.new do |opt| opt.separator "Global options" opt.on("--verbose", "Dump lots of stuff") { |t| verbose(true) } opt.on("--trace", "Turn on tracing") { |t| $trace = true; verbose(true) } end @@plugins.each do |plugin| plugin.new(self) end end |
Class Method Details
.plugin(klass) ⇒ Object
88 89 90 |
# File 'lib/filament.rb', line 88 def self.plugin(klass) @@plugins << klass end |
Instance Method Details
#parse(args) ⇒ Object
121 122 123 |
# File 'lib/filament.rb', line 121 def parse(args) @cmd.parse(args) end |
#run(args) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/filament.rb', line 126 def run(args) verbose(false) if workspace_path.nil? parse(args) else $workspace = Workspace.new(workspace_path) $workspace.load_tasks this_package = $workspace.package_for_realpath(Pathname.pwd.realpath) if this_package.nil? parse(args) else this_package.execute do log "ROOT PACKAGES: #{$context[:package_resolver].root_package_names.join(', ')}" # do it. @cmd.parse(args) end end end end |
#subcommand(name, short_desc, has_subcommands = false, &block) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/filament.rb', line 113 def subcommand(name, short_desc, has_subcommands=false, &block) subcommand = CmdParse::Command.new(name, has_subcommands) subcommand.short_desc = short_desc subcommand.set_execution_block(&block) @cmd.add_command(subcommand) return subcommand end |