Sha256: fab7b3d48d5a83fe05866400538cac86d916c5340472eee21800f5caa014837f
Contents?: true
Size: 1.69 KB
Versions: 27
Compression:
Stored size: 1.69 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'uri' require 'methadone' require 'filesize' require 'segment_upload.rb' class App include Methadone::Main include Methadone::SH include Methadone::CLILogging main do |to_uri,| options['auth_uri'] = options['to_uri'] = URI(to_uri) options['segment-size'] = Filesize.from(options['segment-size']) Uricp::OrbitAuth.validate_options(options) Uricp::OrbitAuth.add_auth_token(options) validate_options run_command end def self.run_command Uricp::Segmenter.new(options).upload end def self.validate_options unless %w{http https}.include? options['to_uri'].scheme raise Uricp::UnsupportedURLtype, "unsupported url: Can only perform a segmented upload to an HTTP(S) URL" end unless options['authenticator'] raise OptionParser::MissingArgument, "Need authentication to proceed - supply 'auth-user' or 'auth-token'" end if options['from'].to_s =~ /^\s*\|/ raise OptionParser::InvalidArgument, "Source filenames starting with '|' not supported" end end # Declare command-line interface here description "Split input into chunks and upload as Dynamic Large Object" options['segment-size'] = Uricp::DEFAULT_SEGMENT_SIZE Uricp::OrbitAuth.add_auth_to_optionparser(self) on("--from FILE", "Upload from FILE rather than stdin") on("--segment-size SEGMENT_SIZE", "Size of required segment in [GMk][i]B.") on("--[no-]dry-run", "Show what would be run,","but don't run the command") #Arguments arg :to_uri, "URI to upload to" defaults_from_env_var 'URICP' version Uricp::VERSION use_log_level_option :toggle_debug_on_signal => 'USR1' go! end
Version data entries
27 entries across 27 versions & 1 rubygems