Module: Pandemonium::CLI
- Defined in:
- lib/pandemonium/cli.rb
Class Method Summary collapse
- .add(repo, script) ⇒ Object
- .colorize(text, color_code) ⇒ Object
- .escape_key(key) ⇒ Object
- .get_projects ⇒ Object
- .help ⇒ Object
- .list ⇒ Object
- .run ⇒ Object
Class Method Details
.add(repo, script) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pandemonium/cli.rb', line 42 def add(repo, script) config = get_projects project_name = File.basename(repo, ".git") repo_name = escape_key(project_name) config[repo_name] = { repository: repo, deploy_script: script, last_run: "", last_status: "" } File.open(Pandemonium::Loader::REPO_FILE, "w") << TOML.dump(config) end |
.colorize(text, color_code) ⇒ Object
38 39 40 |
# File 'lib/pandemonium/cli.rb', line 38 def colorize(text, color_code) "\e[#{color_code}m#{text}\e[0m" end |
.escape_key(key) ⇒ Object
61 62 63 |
# File 'lib/pandemonium/cli.rb', line 61 def escape_key(key) key.tr("-", "_") end |
.get_projects ⇒ Object
57 58 59 |
# File 'lib/pandemonium/cli.rb', line 57 def get_projects TOML.load_file(Pandemonium::Loader::REPO_FILE) end |
.help ⇒ Object
24 25 |
# File 'lib/pandemonium/cli.rb', line 24 def help end |
.list ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pandemonium/cli.rb', line 27 def list get_projects.each do |name, items| if !items["last_status"].to_s.empty? = "#{name}: [#{items["last_run"]}] #{items["deploy_script"]}" puts colorize(, items["last_status"] == 0 ? 32 : 31) else puts "#{name}: #{items["deploy_script"]}" end end end |
.run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pandemonium/cli.rb', line 10 def run # There must be a prettier way to pass options to the runner argv = ["-sv"] argv << "-c" argv << File.join(File.("../../..", __FILE__), "config/pandemonium.rb") runner = Goliath::Runner.new(argv, nil) api = Pandemonium::API runner.api = api.new runner.app = Goliath::Rack::Builder.build(api, runner.api) runner.run end |