Class: ViewServer::Runner

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

Class Method Summary collapse

Class Method Details

.mainObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/view_server/runner.rb', line 41

def self.main
  main = Main.new do
    option 'port', 'p' do
      cast :int
      default 10021
    end

    option 'verbose', 'v' do
      default false
    end

    def run
      puts "serving on port #{params['port']}"
      Server.serve params['port'].value
    end
  end
end

.old_runObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/view_server/runner.rb', line 5

def self.old_run
  options = Clip do |p|
    p.flag 's', 'server',:desc => 'Is a server', :default => false

    p.optional 'p', 'port', :desc => 'The port', :default => 10021 do |v|
      v.to_i # always deal with integers
    end
    p.flag 'c', 'copy_to_clipboard', :desc => "Send to clipboard" 
    p.flag 'P', 'paste_from_clipboard', :desc => "Read from clipboard" 
    p.flag 'v', 'verbose', :desc => 'Make it chatty'
  end

  if options.valid?
    if options.verbose?
      puts options.host
      puts options.port
      puts 'files:'
      options.files.each do |f|
        puts "\t#{f}"
      end
    end
    if options.server?
      Server.serve(options) 
    else
      Client.new(options.port).send(options) 
    end
  else
    # print error message(s) and usage
    $stderr.puts options.to_s
  end
end

.runObject



37
38
39
# File 'lib/view_server/runner.rb', line 37

def self.run 
  main.run
end