Method: Doing::Configuration#choose_config
- Defined in:
- lib/doing/configuration.rb
#choose_config(create: false, local: false) ⇒ String
Present a menu if there are multiple configs found
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/doing/configuration.rb', line 160 def choose_config(create: false, local: false) if local && create res = File.('.doingrc') FileUtils.touch(res) return res end 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.('.doingrc') FileUtils.touch(res) end res.strip || @config_file else @config_file end end |