lib/travis/cli/command.rb in travis-1.6.18.travis.596.5 vs lib/travis/cli/command.rb in travis-1.6.18.travis.604.5

- old
+ new

@@ -45,11 +45,11 @@ on('-E', '--[no-]explode', "don't rescue exceptions") on('--skip-version-check', "don't check if travis client is up to date") on('--skip-completion-check', "don't check if auto-completion is set up") def self.command_name - name[/[^:]*$/].downcase + name[/[^:]*$/].split(/(?=[A-Z])/).map(&:downcase).join('-') end @@abstract ||= [Command] # ignore the man behind the courtains! def self.abstract? @@abstract.include? self @@ -384,9 +384,20 @@ wrong_args("many") if args.any? end def danger_zone?(message) agree(color("DANGER ZONE: ", [:red, :bold]) << message << " ") { |q| q.default = "no" } + end + + def write_file(file, content, force = false) + error "#{file} already exists" unless write_file?(file, force) + File.write(file, content) + end + + def write_file?(file, force) + return true if force or not File.exist?(file) + return false unless interactive? + danger_zone? "Override existing #{color(file, :info)}?" end def wrong_args(quantity) error "too #{quantity} arguments" do say help