## # Build the Backup Command Line Interface using Thor module Backup class CLI < Thor class Error < Backup::Error; end class FatalError < Backup::FatalError; end ## # [Perform] # # The only required option is the --trigger [-t]. # If --config-file, --data-path, --tmp-path or --log-path # aren't specified they will fallback to defaults. # If --root-path is given, it will be used as the base path for our defaults, # as well as the base path for any option specified as a relative path. # Any option given as an absolute path will be used "as-is". # # This command will exit with one of the following status codes: # # 0: All triggers were successful and no warnings were issued. # 1: All triggers were successful, but some had warnings. # 2: All triggers were processed, but some failed. # 3: A fatal error caused Backup to exit. # Some triggers may not have been processed. # # If the --check option is given, `backup check` will be run # and no triggers will be performed. desc "perform", "Performs the backup for the specified trigger(s)." long_desc <<-EOS.gsub(/^ +/, "") Performs the backup for the specified trigger(s). You may perform multiple backups by providing multiple triggers, separated by commas. Each will run in the order specified. $ backup perform --triggers backup1,backup2,backup3,backup4 --root-path may be an absolute path or relative to the current directory. To use the current directory, use: `--root-path .` Relative paths given for --config-file, --data-path, --tmp-path, and --log-path will be relative to --root-path. Console log output may be forced using --no-quiet. Logging to file or syslog may be disabled using --no-logfile or --no-syslog respectively. This will override logging options set in `config.rb`. EOS method_option :trigger, aliases: ["-t", "--triggers"], required: true, type: :string, desc: "Triggers to perform. e.g. 'trigger_a,trigger_b'" method_option :config_file, aliases: "-c", type: :string, default: "", desc: "Path to your config.rb file." method_option :root_path, aliases: "-r", type: :string, default: "", desc: "Root path to base all relative path on." method_option :data_path, aliases: "-d", type: :string, default: "", desc: "Path to store storage cycling data." method_option :log_path, aliases: "-l", type: :string, default: "", desc: "Path to store Backup's log file." method_option :tmp_path, type: :string, default: "", desc: "Path to store temporary data during the backup." # Note that :quiet, :syslog and :logfile are specified as :string types, # so the --no-