Class: Boxafe::CLI
- Inherits:
-
Object
- Object
- Boxafe::CLI
- Defined in:
- lib/boxafe/cli.rb
Instance Method Summary collapse
- #mount(*args) ⇒ Object
- #start(options = {}) ⇒ Object
- #status(options = {}) ⇒ Object
- #stop(options = {}) ⇒ Object
- #unmount(*args) ⇒ Object
Instance Method Details
#mount(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/boxafe/cli.rb', line 33 def mount *args = args.last.kind_of?(Hash) ? args.pop : {} config = load_config # FIXME: crashes with unknown box names boxes = args.empty? ? config.boxes : args.collect{ |arg| config.boxes.find{ |box| box.name == arg } } puts boxes.each do |box| print "Mounting #{box.name}... " if box.mounted? notify :info, "#{box.name} is already mounted", config. puts Paint['already mounted', :green] next end begin box.mount rescue Boxafe::OptionError => e msg = ":#{e.option} option error - #{e.}" notify :error, "#{box.name} #{msg}", config. puts Paint[msg, :red] next end if box.mounted? notify :ok, "#{box.name} is mounted", config. puts Paint['mounted', :green] else notify :error, "#{box.name} could not be mounted", config. puts Paint['could not be mounted', :red] end end puts end |
#start(options = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/boxafe/cli.rb', line 8 def start = {} # TODO: allow to mount only specific boxes # TODO: only allow boxes with an extpass schedule().start end |
#status(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/boxafe/cli.rb', line 18 def status = {} config = load_config puts puts global_description(config, [:verbose]) config.boxes.each do |box| puts puts box_description(box, [:verbose]) end puts end |
#stop(options = {}) ⇒ Object
14 15 16 |
# File 'lib/boxafe/cli.rb', line 14 def stop = {} schedule().stop end |
#unmount(*args) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/boxafe/cli.rb', line 72 def unmount *args = args.last.kind_of?(Hash) ? args.pop : {} config = load_config boxes = args.empty? ? config.boxes : args.collect{ |arg| config.boxes.find{ |box| box.name == arg } } puts boxes.each do |box| print "Umounting #{box.name}... " box.unmount if box.mounted? puts Paint['could not be unmounted', :red] else puts Paint['unmounted', :green] end end puts end |