Class: Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/fresnel/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Cli

Returns a new instance of Cli.



2
3
4
5
# File 'lib/fresnel/cli.rb', line 2

def initialize(argv)
  @argv = argv
  @fresnel = Fresnel.new
end

Instance Method Details

#run!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fresnel/cli.rb', line 7

def run!
  case @argv[0]
    when "projects"
      @fresnel.projects
    when "tickets"
      @fresnel.tickets
    when "bins"
      @fresnel.get_bins
    when "bin"
      @fresnel.get_tickets_in_bin(ARGV[1])
    when "create"
      @fresnel.create
    when "new"
      @fresnel.create_project
    when "help"
      help
    when /\d+/
      if @argv[1]
        case @argv[1]
          when "comment"
            @fresnel.comment(@argv[0])
          when /^(open|closed?|hold|resolved|invalid)$/
            @fresnel.change_state(:ticket=>@argv[0],:state=>@argv[1])
          when "online"
            @fresnel.open_browser_for_ticket(@argv[0])
          when "assign"
            @fresnel.assign(:ticket=>@argv[0])
          when "claim"
            @fresnel.claim(:ticket=>@argv[0])
          when "links"
            @fresnel.links(@argv[0])
          else
            puts Frame.new(:header=>"Notice",:body=>"not sure what to do for #{@argv[1]}")
        end
      else
        @fresnel.show_ticket(@argv[0])
      end
    else
      @fresnel.tickets
      #puts Frame.new(:header=>"Notice",:body=>"not sure what to do for #{@argv[0]}")
  end
end