Module: CLI
- Defined in:
- lib/robot_sweatshop/cli/common.rb,
lib/robot_sweatshop/cli/job.rb,
lib/robot_sweatshop/cli/start.rb,
lib/robot_sweatshop/cli/config.rb
Overview
Methods common to every CLI command
Defined Under Namespace
Modules: Config, Job, Start
Class Method Summary
collapse
Class Method Details
.create(file, with_contents: '') ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# 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) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
|
# 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
|