Class: OptCFBackup
- Inherits:
-
Object
- Object
- OptCFBackup
- Defined in:
- lib/optcfbackup.rb
Overview
Option parser class for CFBackup
Instance Attribute Summary collapse
-
#banner ⇒ Object
readonly
Ussage message.
-
#options ⇒ Object
readonly
Options structure.
Instance Method Summary collapse
-
#initialize(args) ⇒ OptCFBackup
constructor
Implementation of initialize.
Constructor Details
#initialize(args) ⇒ OptCFBackup
Implementation of initialize
Initializes object with command line arguments passed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/optcfbackup.rb', line 15 def initialize(args) @banner = "Usage: cfbackup.rb --action push|pull|delete options --container CONTAINER" @options = OpenStruct.new self..config = ["#{ENV['HOME']}/.cfconfig.yml", './cfconfig.yml', '/etc/cfconfig.yml'] self..action = '' self..pipe_data = false self..show_ver = false self..recursive = false self..local_net = false self..container = '' self..local_path = '' self..remote_path = '' self..verbose = false self..max_retries = 3 self..ignore_errors = false self..error_log = false opts = OptionParser.new do |opts| opts. = self. opts.on("--action ACTION", "Action to perform: push, pull, or delete.") do |action| self..action = action end opts.on("--pipe_data", "Pipe data from another application and stream it to Cloud Files") do |pipe| self..pipe_data = pipe end opts.on("-r", "--recursive", "Traverse local path recursivley") do |recursive| self..recursive = recursive end opts.on("-v", "--verbose", "Run verbosely") do |verbose| self..verbose = verbose end opts.on("--local_path LOCAL_PATH", "Local path or file") do |local_path| self..local_path = local_path end opts.on("--container CONTAINER", "Cloud Files container name") do |name| self..container, self..remote_path = name.split(":", 2) clean_remote_path unless (self..remote_path.nil?) end opts.on("--version", "Show current version") do |version| self..show_ver = version end opts.on("--config_file PATH", "Use specified config file, rather than the default") do |config| self..config = Array.new() self..config << config end opts.on("--local_net", "Use unmetered connection in DFW1 (only applicable to Slicehost or Mosso Cloud Server customers)") do |local_net| self..local_net = local_net end opts.on("--max_retries COUNT", "Change the number of times to retry an operation before giving up.") do |config| self..max_retries = max_retries end opts.on("--ignore_errors", "Ignore file operation errors (push only) and continue processing other files.") do |ignore_errors| self..ignore_errors = ignore_errors end opts.on("--error_log FILEPATH", "Create an error log at the given filepath containing a listing of failed push operations.") do |error_log| self..error_log = error_log end end opts.parse!(args) # Parse arguments end |
Instance Attribute Details
#banner ⇒ Object (readonly)
Ussage message
10 11 12 |
# File 'lib/optcfbackup.rb', line 10 def @banner end |
#options ⇒ Object (readonly)
Options structure
9 10 11 |
# File 'lib/optcfbackup.rb', line 9 def @options end |