Class: Alis::Cmd
- Inherits:
-
Object
- Object
- Alis::Cmd
- Defined in:
- lib/alis/cmd.rb
Instance Attribute Summary collapse
-
#aliases ⇒ Object
Returns the value of attribute aliases.
Class Method Summary collapse
Instance Method Summary collapse
- #add_alias(params, exe, tail) ⇒ Object
- #bin_path ⇒ Object
- #create_bin! ⇒ Object
- #has_bin? ⇒ Boolean
-
#initialize(name) ⇒ Cmd
constructor
A new instance of Cmd.
- #remove ⇒ Object
- #remove_alias(params) ⇒ Object
Constructor Details
Instance Attribute Details
#aliases ⇒ Object
Returns the value of attribute aliases.
4 5 6 |
# File 'lib/alis/cmd.rb', line 4 def aliases @aliases end |
Class Method Details
Instance Method Details
#add_alias(params, exe, tail) ⇒ Object
45 46 47 |
# File 'lib/alis/cmd.rb', line 45 def add_alias(params, exe, tail) @store.set_alias(@name, params, exe, tail) end |
#bin_path ⇒ Object
36 37 38 |
# File 'lib/alis/cmd.rb', line 36 def bin_path File.join(Alis.bin_dir, @name) end |
#create_bin! ⇒ Object
29 30 31 32 33 34 |
# File 'lib/alis/cmd.rb', line 29 def create_bin! FileUtils.mkdir_p(Alis.bin_dir) unless Dir.exists?(Alis.bin_dir) FileUtils.cp(Alis.tpl_path, bin_path) FileUtils.chmod 0755, bin_path end |
#has_bin? ⇒ Boolean
25 26 27 |
# File 'lib/alis/cmd.rb', line 25 def has_bin? FileTest.executable?(bin_path) end |
#remove ⇒ Object
40 41 42 43 |
# File 'lib/alis/cmd.rb', line 40 def remove @store.remove_cmd(@name) FileUtils.rm(bin_path) if has_bin? end |
#remove_alias(params) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/alis/cmd.rb', line 49 def remove_alias(params) if @aliases.size == 1 && @aliases[0] && @aliases[0].params == params remove else @store.remove_alias(@name, params) end end |