Created
June 18, 2012 13:43
-
-
Save adamgamble/2948442 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'thor' | |
require 'dcell' | |
require 'yaml' | |
require 'command_line_reporter' | |
class Filez < Thor | |
include CommandLineReporter | |
APP_CONFIG = YAML.load(File.read("config.yml")) | |
desc "list_nodes", "List nodes on the network" | |
def list_nodes | |
DCell.setup :id => APP_CONFIG["id"], :directory => {:id => APP_CONFIG["directory"]["id"], :addr => APP_CONFIG["directory"]["addr"]} | |
DCell.run! | |
nodes = DCell::Node.all | |
table(:border => true) do | |
row do | |
column('NAME', :width => 20) | |
end | |
nodes.each do |node| | |
row do | |
column(node.id) | |
end | |
end | |
end | |
end | |
desc "list_files", "List all the files a node is sharing" | |
method_option :node, :type => :string, :required => true | |
def list_files | |
DCell.setup :id => APP_CONFIG["id"], :directory => {:id => APP_CONFIG["directory"]["id"], :addr => APP_CONFIG["directory"]["addr"]} | |
DCell.run! | |
node = DCell::Node[options[:node]] | |
puts node[:file_server] | |
table(:border => true) do | |
row do | |
column('NAME', :width => 20) | |
end | |
files.each do |file| | |
row do | |
column(file) | |
end | |
end | |
end | |
end | |
end | |
Filez.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment