Module: CommandKit::Edit

Includes:
Env
Defined in:
lib/command_kit/edit.rb

Overview

Allows invoking the EDITOR environment variable.

Environment Variables

  • EDITOR - The preferred editor command.

Example

if options[:edit]
  edit CONFIG_FILE
end

Since:

  • 0.4.0

Instance Attribute Summary

Attributes included from Env

#env

Instance Method Summary collapse

Methods included from Env

#initialize

Instance Method Details

#edit(*arguments) ⇒ Boolean?

Invokes the preferred editor with the additional arguments.

Parameters:

  • arguments (Array)

    The additional arguments to pass to the editor command.

Returns:

  • (Boolean, nil)

    Indicates whether the editor successfully launched and exited. If the #editor command was not installed, nil will be returned.

Since:

  • 0.4.0



48
49
50
51
52
# File 'lib/command_kit/edit.rb', line 48

def edit(*arguments)
  if editor
    system(editor,*arguments.map(&:to_s))
  end
end

#editorString

The EDITOR environment variable.

Returns:

  • (String)

    The EDITOR environment variable, or "nano" if EDITOR was not set.

Since:

  • 0.4.0



32
33
34
# File 'lib/command_kit/edit.rb', line 32

def editor
  env['EDITOR'] || 'nano'
end