class CollinsShell::State

Public Class Methods

banner(task, namespace = true, subcommand = false) click to toggle source

Public Instance Methods

create() click to toggle source
# File lib/collins_shell/state.rb, line 23
def create
  name = options.name.upcase
  label = options.label
  desc = options.description
  status = options.status
  call_collins get_collins_client, "state_create!" do |client|
    if client.state_create!(name, label, desc, status) then
      say_success "Successfully created state '#{name}'"
    else
      say_error "Failed creating state '#{name}'"
    end
  end
end
delete(state) click to toggle source
# File lib/collins_shell/state.rb, line 39
def delete state
  call_collins get_collins_client, "state_delete!" do |client|
    if client.state_delete!(state) then
      say_success "Successfully deleted state '#{state}'"
    else
      say_error "Failed deleting state '#{state}'"
    end
  end
end
get(state) click to toggle source
# File lib/collins_shell/state.rb, line 51
def get state
  call_collins get_collins_client, "state_get" do |client|
    header = [["Name", "Label", "Status", "Description"]]
    state = client.state_get(state)
    table = header + [[state.name, state.label, (state.status.name || ""), state.description]]
    print_table table
  end
end
list() click to toggle source
# File lib/collins_shell/state.rb, line 62
def list
  call_collins get_collins_client, "state_get_all" do |client|
    header = [["Name", "Label", "Status", "Description"]]
    states = header + client.state_get_all.map do |state|
      [state.name, state.label, (state.status.name || ""), state.description]
    end
    print_table states
  end
end
update(state) click to toggle source
# File lib/collins_shell/state.rb, line 78
def update state
  name = options.name.upcase if options.name?
  label = options.label if options.label?
  desc = options.description if options.description?
  status = options.status if options.status?
  call_collins get_collins_client, "state_update!" do |client|
    opts = {
      :name => name, :label => label, :status => status,
      :description => desc
    }
    if client.state_update!(state, opts) then
      say_success "Successfully updated state '#{state}'"
    else
      say_error "Failed creating state '#{state}'"
    end
  end
end