bin/rmega-up in rmega-0.2.0 vs bin/rmega-up in rmega-0.2.1
- old
+ new
@@ -12,20 +12,30 @@
end
OptionParser.new do |opts|
opts.banner = "Usage:\n"
opts.banner << "\t#{File.basename(__FILE__)} path [options]\n"
+ opts.banner << "Examples:\n"
+ opts.banner << "\t#{File.basename(__FILE__)} /local/file.txt -u email@localhost -r /remote/docs\n"
opts.banner << "Options:"
+ opts.on("-r PATH", "--remote-path", "Remote path") { |path|
+ cli_options[:remote_path] = path
+ }
+
apply_opt_parser_options(opts)
end.parse!
-rescue_errors_and_inerrupt do
+cli_rescue do
raise("File not found - #{cli_options[:path]}") unless File.exists?(cli_options[:path])
user = cli_options[:user] || raise("User email is required")
- pass = cli_options[:pass] ||= cli_prompt_password
+ session = Rmega::Session.new.login(user, cli_options[:pass] ||= cli_prompt_password)
- session = Rmega::Session.new.login(user, pass)
root = session.storage.root
- root.upload(cli_options[:path])
+ node = traverse_storage(root, cli_options[:remote_path].to_s.dup, :only_folders => true)
+
+ raise("Node not found - #{cli_options[:remote_path]}") unless node
+ raise("Node cannot be a file - #{cli_options[:remote_path]}") if node.type == :file
+
+ node.upload(cli_options[:path])
end