Module: GHI::CLI::FileHelper

Included in:
Executable
Defined in:
lib/ghi/cli.rb

Instance Method Summary collapse

Instance Method Details

#delete_messageObject



35
36
37
38
39
# File 'lib/ghi/cli.rb', line 35

def delete_message
  File.delete message_path
rescue Errno::ENOENT, TypeError
  nil
end

#gets_from_editor(issue) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ghi/cli.rb', line 19

def gets_from_editor(issue)
  if windows?
    warn "Please supply the message with the -m option"
    exit 1
  end

  if in_repo?
    File.open message_path, "a+", &file_proc(issue)
  else
    Tempfile.open message_filename, &file_proc(issue)
  end

  return @message if comment?
  return @message.shift.strip, @message.join.sub(/\b\n\b/, " ").strip
end

#launch_editor(file) ⇒ Object



15
16
17
# File 'lib/ghi/cli.rb', line 15

def launch_editor(file)
  system "#{editor} #{file.path}"
end

#message_pathObject



41
42
43
# File 'lib/ghi/cli.rb', line 41

def message_path
  File.join gitdir, message_filename
end