Class: Mirrorworks

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

Instance Method Summary collapse

Constructor Details

#initializeMirrorworks

Returns a new instance of Mirrorworks.



11
12
13
14
15
# File 'lib/mirrorworks.rb', line 11

def initialize
  @help_msg = ''
  @options = {}
  @conf = {}
end

Instance Method Details

#run(args) ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/mirrorworks.rb', line 128

def run(args)
  begin
    OptionParser.new do |opts|
      opts.banner = 'Usage: mirrorworks [options] <command> [reflections]'
      opts.on('-V', '--version', 'print version and exit') {version}
      opts.on('-h', '--help', 'print help and exit') {help}
      opts.on('-x', '--hard', 'delete extra files on transfer') do |x|
        @options[:x] = x
      end
      @help_msg = opts.to_s
    end.parse! args

    help if args.empty?

    command = args.shift
    parse_config unless command == 'install'
    case command
    when 'push'
      push args
    when 'pull'
      pull args
    when 'status'
      status args
    when 'list'
      list args
    when 'install'
      install
    else
      raise "No command '#{command}'"
    end
  rescue Exception => e
    puts e.message unless e.is_a? SystemExit
  end
end