#!/usr/bin/env ruby # # == Synopsis # Nodes is a data warehouse in the form of meta tags, which may have additional values. # Users can add, delete, edit nodes, manage access rights, etc. # # == Examples # This command add new point. # point add "{ name: 'test point', tag: test, zero, one: 1, two: [1,2] }" # # Other examples: # point find "{ name, tag, zero }" # point del "{ name, tag, zero, one, two }" # # == Usage # point [options] json_text/file.yml # # For help use: point -h # # == Options # -h, --help Displays help message # -v, --version Display the version, then exit # TO DO - add additional options # # == Author # Eugene Markine # # == Copyright # Copyright (c) 2010 EugeneLab. Licensed under the GNU General Public License (GPL), Version 2: # http://www.opensource.org/licenses/gpl-2.0.php # TO DO - change license if necessary #require 'rubygems' #require "nodes" require "#{File.dirname(__FILE__)}/../lib/nodes" commands_help = "Commands:\n" \ " init Init new point\n" \ " del Delete point \n" \ " clone Clone point from server\n" \ " put Put changes to server\n" \ " get Get changes from server\n" \ " size Size of point\n" \ "\n" # " country Extract a country name from IP address\n" usage_help = "usage: point command [arguments...] [options...]\n\n" + commands_help unless ARGV.first puts "Nodes #{Nodes::VERSION}" puts usage_help exit end command = ARGV.shift dir = ARGV.first dir = Dir.pwd unless dir #puts "find: #{ARGV.find "-h"}" case command when 'version' puts "Nodes #{Nodes::VERSION}" when 'init' Nodes.init dir Nodes.put dir when 'clone' name = ARGV.first unless name puts "You must specify a name to clone.\n\n" puts "usage: point clone \n\n" exit end Nodes.clone name when 'put' Nodes.put dir when 'get' Nodes.get dir when 'del' Nodes.del dir when 'size' Nodes.size dir when 'country' Nodes.country(ARGV.shift) else puts "Unknown command: #{command}\n" puts commands_help end