#!/usr/bin/env ruby #onering # list [options] field [key:value ..] # search [options] [key:value .. ] # provision [options] [key:value .. ] [pxe profile | ] require 'rubygems' require 'json' require 'subcommander' require 'onering' Onering::API::Device.connect action = ARGV.shift case (action && action.to_sym) when :ls, :list Onering::API::Device.list(ARGV.shift, (ARGV.empty? ? {} : { :filter => ARGV })) when :s, :search Onering::API::Device.find(ARGV) when :save data = (STDIN.tty? && ARGV.length > 1 ? File.read(File.expand_path(ARGV.last)) : STDIN.read) if data data = JSON.load(data) Onering::API::Device.save(ARGV.first, data) end else STDERR.puts "Usage: onering [subcommand] [options]" end