module CLI
Methods common to every CLI
command
Public Class Methods
create(file, with_contents: '')
click to toggle source
# File lib/robot_sweatshop/cli/common.rb, line 19 def self.create(file, with_contents: '') file = File.expand_path file if File.file?(file) Announce.info "'#{file}' already exists" else FileUtils.mkdir_p File.dirname(file) File.write file, with_contents Announce.success "Created new file '#{file}'" end end
edit(file)
click to toggle source
# File lib/robot_sweatshop/cli/common.rb, line 7 def self.edit(file) editor = ENV['EDITOR'] if editor Announce.info "Manually editing file '#{file}'" system editor, file else Announce.warning 'No editor specified in $EDITOR environment variable' Announce.info 'Displaying file contents instead' system 'cat', file end end