Class: Dk::CLI
- Inherits:
-
Object
- Object
- Dk::CLI
- Defined in:
- lib/dk/cli.rb
Constant Summary collapse
- DEFAULT_CONFIG_PATH =
'config/dk.rb'.freeze
Instance Attribute Summary collapse
-
#clirb ⇒ Object
readonly
Returns the value of attribute clirb.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(kernel = nil) ⇒ CLI
constructor
A new instance of CLI.
- #run(*args) ⇒ Object
Constructor Details
#initialize(kernel = nil) ⇒ CLI
Returns a new instance of CLI.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dk/cli.rb', line 19 def initialize(kernel = nil) @kernel = kernel || Kernel load config_path Dk.init @config = Dk.config @clirb = CLIRB.new do option 'list-tasks', 'list all tasks available to run', { :abbrev => 'T' } option 'dry-run', 'run the tasks without executing any local/remote cmds' option 'tree', 'print out the tree of tasks/sub-tasks that would be run' option 'verbose', 'run tasks showing verbose (ie debug log level) details' end end |
Instance Attribute Details
#clirb ⇒ Object (readonly)
Returns the value of attribute clirb.
17 18 19 |
# File 'lib/dk/cli.rb', line 17 def clirb @clirb end |
Class Method Details
.run(args) ⇒ Object
13 14 15 |
# File 'lib/dk/cli.rb', line 13 def self.run(args) self.new.run(*args) end |
Instance Method Details
#run(*args) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dk/cli.rb', line 36 def run(*args) begin run!(*args) rescue ShowTaskList @kernel.puts task_list rescue CLIRB::HelpExit @kernel.puts help rescue CLIRB::VersionExit @kernel.puts Dk::VERSION rescue CLIRB::Error, Dk::Config::UnknownTaskError => exception @kernel.puts help @kernel.puts "\n\n#{exception.message}\n" @kernel.exit 1 rescue Dk::NoticeError => exception @kernel.puts "\n\n#{exception.message}\n\n" @kernel.puts exception.backtrace.first @kernel.exit 1 rescue StandardError => exception @kernel.puts "\n\n#{exception.class}: #{exception.message}" @kernel.puts exception.backtrace.join("\n") @kernel.exit 1 end @kernel.exit 0 end |