Class: ColorLS::Flags

Inherits:
Object
  • Object
show all
Defined in:
lib/colorls/flags.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Flags

Returns a new instance of Flags.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/colorls/flags.rb', line 9

def initialize(*args)
  @args = args
  @light_colors = false

  @opts = default_opts
  @report_mode = false
  @exit_status_code = 0

  parse_options

  return unless @opts[:mode] == :tree

  # FIXME: `--all` and `--tree` do not work together, use `--almost-all` instead
  @opts[:almost_all] = true if @opts[:all]
  @opts[:all] = false
end

Instance Method Details

#optionsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/colorls/flags.rb', line 34

def options
  list = @parser.top.list + @parser.base.list

  result = list.collect do |o|
    next unless o.respond_to? :desc

    flags = o.short + o.long
    next if flags.empty?

    OpenStruct.new(flags: flags, desc: o.desc)
  end

  result.compact
end

#processObject



26
27
28
29
30
31
32
# File 'lib/colorls/flags.rb', line 26

def process
  init_locale

  @args = ['.'] if @args.empty?

  process_args
end