Module: Fontist::CLI::ClassOptions

Included in:
Fontist::CLI, Fontist::CacheCLI, Fontist::ConfigCLI, FontconfigCLI, ImportCLI, RepoCLI
Defined in:
lib/fontist/cli/class_options.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

rubocop:disable Metrics/MethodLength



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fontist/cli/class_options.rb', line 5

def self.included(base)
  base.class_option :preferred_family,
                    type: :boolean,
                    desc: "Use Preferred Family when available"

  base.class_option :quiet,
                    aliases: :q,
                    type: :boolean,
                    desc: "Hide all messages"

  base.class_option :verbose,
                    aliases: :v,
                    type: :boolean,
                    desc: "Print debug messages"

  base.class_option :no_cache,
                    aliases: :c,
                    type: :boolean,
                    desc: "Avoid using cache during download"

  base.class_option :interactive,
                    aliases: :i,
                    type: :boolean,
                    default: true,
                    desc: "Interactive mode"

  base.class_option :formulas_path,
                    type: :string,
                    desc: "Path to formulas"
end

Instance Method Details

#handle_class_options(options) ⇒ Object

rubocop:enable Metrics/MethodLength



37
38
39
40
41
42
43
44
45
46
# File 'lib/fontist/cli/class_options.rb', line 37

def handle_class_options(options)
  Fontist.preferred_family = options[:preferred_family]
  Fontist.log_level = log_level(options)
  Fontist.use_cache = !options[:no_cache]
  Fontist.interactive = options[:interactive]

  if options[:formulas_path]
    Fontist.formulas_path = Pathname.new(options[:formulas_path])
  end
end

#log_level(options) ⇒ Object



48
49
50
51
52
53
# File 'lib/fontist/cli/class_options.rb', line 48

def log_level(options)
  return :debug if options[:verbose]
  return :fatal if options[:quiet]

  :info
end