Class: Imap::Backup::CLI::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/cli/options.rb

Overview

Defines option methods for CLI classes

Constant Summary collapse

OPTIONS =

Options common to many commands

[ { name: "accounts", parameters: { type: :string, aliases: ["-a"], desc: "a comma-separated list of accounts (defaults to all configured accounts)" } }, { name: "config", parameters: { type: :string, aliases: ["-c"], desc: "supply the configuration file path (default: ~/.imap-backup/config.json)" } }, { name: "format", parameters: { type: :string, desc: "the output type, 'text' for plain text or 'json'", aliases: ["-f"] } }, { name: "quiet", parameters: { type: :boolean, desc: "silence all output", aliases: ["-q"] } }, { name: "refresh", parameters: { type: :boolean, aliases: ["-r"], desc: "in the default 'keep all emails' mode, " \ "updates flags for messages that are already downloaded" } }, { name: "verbose", parameters: { type: :boolean, aliases: ["-v"], repeatable: true, desc: "increase the amount of logging. " \ "Without this option, the program gives minimal output. " \ "Using this option once gives more detailed output. " \ "Whereas, using this option twice also shows all IMAP network calls" } } ].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base:) ⇒ Options

Returns a new instance of Options.

 60 61 62
# File 'lib/imap/backup/cli/options.rb', line 60 def initialize(base:) @base = base end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.

 10 11 12
# File 'lib/imap/backup/cli/options.rb', line 10 def base @base end

Instance Method Details

#define_optionsObject

 64 65 66 67 68 69 70 71 72
# File 'lib/imap/backup/cli/options.rb', line 64 def define_options OPTIONS.each do |option| base.singleton_class.class_eval do define_method("#{option[:name]}_option") do method_option(option[:name], **option[:parameters]) end end end end