Class: Ecic::CLI
- Includes:
- SourceListUpdater
- Defined in:
- lib/ecic/cli.rb
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Make sure to return non-zero value if an error is thrown.
- .help(shell, subcommand = false) ⇒ Object
Instance Method Summary collapse
- #addfile(*file_names) ⇒ Object
- #completion(*params) ⇒ Object
- #completion_script ⇒ Object
- #libraries ⇒ Object
- #new(path) ⇒ Object
- #version ⇒ Object
Methods included from SourceListUpdater
Methods inherited from Command
Class Method Details
.exit_on_failure? ⇒ Boolean
Make sure to return non-zero value if an error is thrown.
20 21 22 |
# File 'lib/ecic/cli.rb', line 20 def self.exit_on_failure? true end |
.help(shell, subcommand = false) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/ecic/cli.rb', line 7 def help(shell, subcommand = false) shell.say "Usage: ecic COMMAND [ARGS]" shell.say "" super shell.say "Commands may be abbreviated, so long as they are unambiguous." shell.say "E.g. 'ecic p r' is short for 'ecic project root'." shell.say "\nTo get more help on a specific command, try 'ecic help [COMMAND]'" end |
Instance Method Details
#addfile(*file_names) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ecic/cli.rb', line 65 def addfile(*file_names) begin root_dir = Project::root if root_dir.nil? shell.error set_color("You must be within an ECIC project before calling this command",Thor::Shell::Color::RED) exit(1) end opt = {"lib" => nil}.merge() project = Project.new(root_dir) project.load_libraries lib_name = opt['lib'] file_adder = FileAdder.new file_adder.destination_root = root_dir file_adder.library_name = lib_name file_adder.project = project file_adder.file_names = file_names file_adder.invoke_all rescue Exception => exc shell.error set_color(exc., Thor::Shell::Color::RED) exit(3) end end |
#completion(*params) ⇒ Object
96 97 98 |
# File 'lib/ecic/cli.rb', line 96 def completion(*params) Completer.new(CLI, *params).run end |
#completion_script ⇒ Object
105 106 107 |
# File 'lib/ecic/cli.rb', line 105 def completion_script Completer::Script.generate end |
#libraries ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ecic/cli.rb', line 124 def libraries begin defaults = { "format" => "text", "include_source_files" => false } opt = defaults.merge() root_dir = Project::root if root_dir.nil? shell.error set_color("You must be within an ECIC project before calling this command",Thor::Shell::Color::RED) exit(3) end project = Project.new(root_dir) project.load_libraries if opt['include_source_files'] project.load_sources end if opt['format'] == 'json' require 'json' say project.libraries.map{ |lib| lib.to_json(:include_source_files => opt['include_source_files']) }.join(",") else say project.libraries.map{ |lib| lib.to_s(:include_source_files => opt['include_source_files']) }.join("\n") end rescue Exception => exc shell.error set_color(exc., Thor::Shell::Color::RED) exit(3) end end |
#new(path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ecic/cli.rb', line 30 def new(path) path = File.(path) shell.say "Generating a new project in #{path}" generator = ProjectGenerator.new generator.destination_root = path generator.invoke_all shell.say "\nTo install the required packages in your project, please run:\n cd #{path}; bundle install\n", Thor::Shell::Color::BOLD #TBA: invoke installation by eg. calling 'bundler install' from within the generated project folder # Bundler.with_clean_env do # Dir.chdir(path) do # `bundle install` # end # end end |
#version ⇒ Object
113 114 115 |
# File 'lib/ecic/cli.rb', line 113 def version say "#{VERSION}" end |