Method: Doing::Configuration#choose_config

Defined in:
lib/doing/configuration.rb

#choose_config(create: false) ⇒ String

Present a menu if there are multiple configs found

Returns:



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/doing/configuration.rb', line 158

def choose_config(create: false)
  return @config_file if @force_answer

  if @additional_configs.count.positive? || create
    choices = [@config_file].concat(@additional_configs)
    choices.push('Create a new .doingrc in the current directory') if create && !File.exist?('.doingrc')
    res = Doing::Prompt.choose_from(choices.uniq.sort.reverse,
                                    sorted: false,
                                    prompt: 'Local configs found, select which to update > ')

    raise UserCancelled, 'Cancelled' unless res

    if res =~ /^Create a new/
      res = File.expand_path('.doingrc')
      FileUtils.touch(res)
    end

    res.strip || @config_file
  else
    @config_file
  end
end