Class: DevOops::Commands::EditScriptSh

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/dev_oops/commands/edit_script_sh.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



17
18
19
# File 'lib/dev_oops/commands/edit_script_sh.rb', line 17

def self.banner
  "#{$PROGRAM_NAME} edit_sh SCRIPT_NAME"
end

.source_rootObject



7
8
9
# File 'lib/dev_oops/commands/edit_script_sh.rb', line 7

def self.source_root
  "#{File.dirname(__FILE__)}/../../../"
end

Instance Method Details

#editObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dev_oops/commands/edit_script_sh.rb', line 21

def edit
  script_dir =
    if options[:global]
      ScriptsLoader::GLOBAL_DIR
    else
      ScriptsLoader.script_dir(script_name)
    end
  path = "#{script_dir}/#{script_name}.sh"
  create_file(path) unless File.exist?(path)
  FileUtils.chmod(0o750, path)
  system("#{ENV['EDITOR'] || 'vim'} #{path}")
end