Class: Norikra::Client::Target

Inherits:
Thor
  • Object
show all
Includes:
CLIUtil
Defined in:
lib/norikra/client/cli.rb

Instance Method Summary collapse

Methods included from CLIUtil

#client, #formatter, #parser, #wrap

Instance Method Details

#close(target) ⇒ Object



59
60
61
62
63
# File 'lib/norikra/client/cli.rb', line 59

def close(target)
  wrap do
    client(parent_options).close(target)
  end
end

#listObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/norikra/client/cli.rb', line 29

def list
  wrap do
    puts ["TARGET","AUTO_FIELD"].join("\t") unless options[:simple]
    targets = client(parent_options).targets
    targets.each do |t|
      puts [t['name'], t['auto_field']].join("\t")
    end
    puts "#{targets.size} targets found." unless options[:simple]
  end
end

#modify(target, val) ⇒ Object



66
67
68
69
70
71
# File 'lib/norikra/client/cli.rb', line 66

def modify(target, val)
  auto_field = ['yes','true','auto'].include?(val.downcase)
  wrap do
    client(parent_options).modify(target, auto_field)
  end
end

#open(target, *field_defs) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/norikra/client/cli.rb', line 42

def open(target, *field_defs)
  fields = nil
  if field_defs.size > 0
    fields = {}
    field_defs.each do |str|
      fname,ftype = str.split(':')
      fields[fname] = ftype
    end
  end
  auto_field = (not options[:suppress_auto_field])

  wrap do
    client(parent_options).open(target, fields, auto_field)
  end
end