Sha256: e1db2e7c6574e6b5a221168bc34d5574c567c7cca4bdaca5663eee9967ddc25c

Contents?: true

Size: 653 Bytes

Versions: 5

Compression:

Stored size: 653 Bytes

Contents

# encoding: utf-8

module GithubCLI
  # This class determines editor to use to open the output.
  class Editor

    def initialize(options={})
    end

    def editor
      editors = [ ENV['GHC_EDITOR'], ENV['VISUAL'], ENV['EDITOR'], 'vi' ]
      editor = GithubCLI.config['editor']
      editor ||= editors.find { |e| !e.nil? && !e.empty? }
    end

    def open(name)
      if editor
        command = "#{editor} #{name}"
        success = system(command)
        GithubCLI.ui.info "Could not run '#{command}'" unless success
      else
        GithubCLI.info("To open output, set $EDITOR or $VISUL")
      end
    end

  end # Editor
end # GithubCLI

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
github_cli-0.4.4 lib/github_cli/editor.rb
github_cli-0.4.3 lib/github_cli/editor.rb
github_cli-0.4.2 lib/github_cli/editor.rb
github_cli-0.4.1 lib/github_cli/editor.rb
github_cli-0.4.0 lib/github_cli/editor.rb