Class: Commanding::Install
- Inherits:
-
Commanding
- Object
- CLAide::Command
- Commanding
- Commanding::Install
- Defined in:
- lib/commanding.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Install
constructor
A new instance of Install.
- #run ⇒ Object
- #shell_path ⇒ Object
- #validate! ⇒ Object
Methods inherited from Commanding
Constructor Details
#initialize(argv) ⇒ Install
Returns a new instance of Install.
32 33 34 35 36 |
# File 'lib/commanding.rb', line 32 def initialize(argv) @new_command_name = argv.shift_argument @shell_relative_path = argv.shift_argument super end |
Instance Method Details
#run ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/commanding.rb', line 45 def run `cd ~` file = nil if File.exists?(shell_config_path) file = File.open(shell_config_path, 'a+') else file = File.new(shell_config_path, 'w') end file.write("\n") file.write("alias #{@new_command_name}=\"#{@shell_path}\"") file.close end |
#shell_path ⇒ Object
59 60 61 62 63 64 |
# File 'lib/commanding.rb', line 59 def shell_path if !@shell_path @shell_path = File.(@shell_relative_path, Dir.pwd) end @shell_path end |
#validate! ⇒ Object
38 39 40 41 42 43 |
# File 'lib/commanding.rb', line 38 def validate! super help! 'Please make sure new_command_name needed!' unless @new_command_name help! 'A shell_file_path is required.' unless @shell_relative_path help! "The #{@shell_relative_path} is invalid!!" unless File.exists?(shell_path) end |