#!/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 node. # node add "{ name: 'test node', tag: test, zero, one: 1, two: [1,2] }" # # Other examples: # node find "{ name, tag, zero }" # node del "{ name, tag, zero, one, two }" # # == Usage # node [options] json_text/file.yml # # For help use: node -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 "#{__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" \ "\n" # " country Extract a country name from IP address\n" usage_help = "usage: node command [arguments...] [options...]\n\n" + commands_help unless ARGV.first puts "Nodes #{Nodes::VERSION}" puts usage_help exit end command = ARGV.shift case command when 'version' puts "Nodes #{Nodes::VERSION}" when 'init' dir = ARGV.shift Nodes.init dir Nodes.put dir when 'clone' name = ARGV.shift unless name puts "You must specify a name to clone.\n\n" puts "usage: node clone \n\n" exit end Nodes.clone name when 'put' Nodes.put ARGV.shift when 'get' Nodes.get ARGV.shift when 'del' Nodes.del ARGV.shift when 'country' Nodes.country(ARGV.shift) else puts "Unknown command: #{command}\n" puts commands_help end