Class: Commanding::Uninstall

Inherits:
Commanding
  • Object
show all
Defined in:
lib/commanding.rb

Instance Method Summary collapse

Methods inherited from Commanding

#shell_config_path

Constructor Details

#initialize(argv) ⇒ Uninstall



73
74
75
76
# File 'lib/commanding.rb', line 73

def initialize(argv)
  @installed_command_name = argv.shift_argument
  super
end

Instance Method Details

#runObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/commanding.rb', line 84

def run
    `cd ~`
    if File.exists?(shell_config_path)
      file = File.open(shell_config_path, 'r+')
      file.each do |line|
        if line.start_with?("alias " + @installed_command_name)
          file.seek(-line.length, IO::SEEK_CUR)
          file.write(' ' * (line.length - 1))
          file.write("\n")
        end
      end

      file.close
    else
      help! 'No #{@installed_command_name}, nothing to remove.'
    end

end

#validate!Object



78
79
80
81
82
# File 'lib/commanding.rb', line 78

def validate!
super
help! 'Please make sure installed_command_name needed!' unless @installed_command_name

end