abhishekkr/ci-go-nfo

View on GitHub
bin/ci-go-nfo

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'

require 'ci-go-nfo'

if ARGV.size === 0
  Ci::Go::Nfo.builds
elsif ARGV.size === 1
  case ARGV[0]
  when 'help', '-h', '--help', '?'
    puts <<-HELP
    \e[1m\e[31mCi-Go-Nfo ver.#{Ci::Go::Nfo::VERSION}\e[0m
    to set-up credential config for your go-ci\e[33m
    $ ci-go-nfo setup\e[0m
    to show go-ci info of all runs\e[33m
    $ ci-go-nfo\e[0m
    to show go-ci info of failed runs\e[33m
    $ ci-go-nfo fail\e[0m
    to show go-ci info of passed runs\e[33m
    $ ci-go-nfo pass\e[0m
    \e[32m_____
    \e[33m.....more to come
    \e[0m
    HELP
  when 'setup'
    Ci::Go::Access.persist_config
  when nil
    Ci::Go::Nfo.builds
  when 'pass'
    Ci::Go::Nfo.builds 'pass'
  when 'fail'
    Ci::Go::Nfo.builds 'fail'
  when 'summary'
    Ci::Go::Nfo.summary
  end

elsif ARGV.size === 2
  argv = ARGV
  status = ['pass', 'fail']
  detail = ['dep', 'history']
  filter = [status, detail].flatten.select{|s| argv.delete status}

  if status.include? filter
    Ci::Go::Nfo.builds filter, argv
  elsif filter === 'dep'
    # would
  end
end