Sha256: d5139350d29d26ffb4ee5b885df4f430828232a23b1f624ce0ec1046ded344c5

Contents?: true

Size: 686 Bytes

Versions: 7

Compression:

Stored size: 686 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: 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

7 entries across 7 versions & 1 rubygems

Version Path
friends-0.55 lib/friends/commands/edit.rb
friends-0.54 lib/friends/commands/edit.rb
friends-0.53 lib/friends/commands/edit.rb
friends-0.52 lib/friends/commands/edit.rb
friends-0.51 lib/friends/commands/edit.rb
friends-0.50 lib/friends/commands/edit.rb
friends-0.49 lib/friends/commands/edit.rb