class Ecic::CLI
Public Class Methods
exit_on_failure?()
click to toggle source
Make sure to return non-zero value if an error is thrown.
# File lib/ecic/cli.rb, line 20 def self.exit_on_failure? true end
help(shell, subcommand = false)
click to toggle source
Calls superclass method
# 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
Public Instance Methods
addfile(*file_names)
click to toggle source
# 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(options) 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.message, Thor::Shell::Color::RED) exit(3) end end
completion(*params)
click to toggle source
# File lib/ecic/cli.rb, line 96 def completion(*params) Completer.new(CLI, *params).run end
completion_script()
click to toggle source
# File lib/ecic/cli.rb, line 105 def completion_script Completer::Script.generate end
libraries()
click to toggle source
# File lib/ecic/cli.rb, line 124 def libraries begin defaults = { "format" => "text", "include_source_files" => false } opt = defaults.merge(options) 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.message, Thor::Shell::Color::RED) exit(3) end end
new(path)
click to toggle source
# File lib/ecic/cli.rb, line 30 def new(path) path = File.expand_path(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()
click to toggle source
# File lib/ecic/cli.rb, line 113 def version say "#{VERSION}" end