Sha256: be5426a761bf8b4cd5ea9d09ac749059f1033f5b7b19b01b5e787bf5d5a951c3

Contents?: true

Size: 703 Bytes

Versions: 8

Compression:

Stored size: 703 Bytes

Contents

# frozen_string_literal: true

desc "Opens the `friends.md` file in $EDITOR for manual editing"
command :edit do |edit|
  edit.action do |global_options|
    editor = ENV["EDITOR"] || "vim"
    filename = global_options[:filename]

    puts "Opening \"#{filename}\" with \"#{editor}\"" unless global_options[:quiet]

    # Mark the file for cleaning once the editor was closed correctly.
    if Kernel.system("#{editor} #{filename}")
      @introvert = Friends::Introvert.new(filename: global_options[:filename])
      @clean_command = true
      @dirty = true
    elsif !global_options[:quiet]
      puts "Not cleaning file: \"#{filename}\" (\"#{editor}\" did not exit successfully)"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
friends-0.47 lib/friends/commands/edit.rb
friends-0.46 lib/friends/commands/edit.rb
friends-0.45 lib/friends/commands/edit.rb
friends-0.44 lib/friends/commands/edit.rb
friends-0.43 lib/friends/commands/edit.rb
friends-0.42 lib/friends/commands/edit.rb
friends-0.41 lib/friends/commands/edit.rb
friends-0.40 lib/friends/commands/edit.rb