12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/furaffinity/cli_utils.rb', line 12
def open_editor(file, fatal: false)
editor = ENV["FA_EDITOR"] || ENV["VISUAL"] || ENV.fetch("EDITOR", nil)
unless editor
logger.warn "could not open editor for #{file.inspect}, set one of FA_EDITOR, VISUAL, or EDITOR in your ENV"
if fatal
raise "No suitable editor found to edit #{file.inspect}, set one of FA_EDITOR, VISUAL, or EDITOR in your ENV"
end
return
end
system(*Shellwords.shellwords(editor), file).tap do
next if $CHILD_STATUS.exitstatus.zero?
logger.error "could not run #{editor} #{file}, exit code: #{$CHILD_STATUS.exitstatus}"
end
end
|