Class: Awestruct::CLI::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/cli/options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/awestruct/cli/options.rb', line 23

def initialize()
  @generate  = nil
  @server    = false
  @port      = 4242
  @bind_addr = '0.0.0.0'
  @auto      = false
  @force     = false
  @init      = false
  @framework = 'compass'
  @scaffold  = true
  @base_url  = nil
  @profile   = nil
  @deploy    = false
  @script    = nil
end

Instance Attribute Details

#autoObject

Returns the value of attribute auto.



13
14
15
# File 'lib/awestruct/cli/options.rb', line 13

def auto
  @auto
end

#base_urlObject

Returns the value of attribute base_url.



18
19
20
# File 'lib/awestruct/cli/options.rb', line 18

def base_url
  @base_url
end

#bind_addrObject

Returns the value of attribute bind_addr.



12
13
14
# File 'lib/awestruct/cli/options.rb', line 12

def bind_addr
  @bind_addr
end

#deployObject

Returns the value of attribute deploy.



20
21
22
# File 'lib/awestruct/cli/options.rb', line 20

def deploy
  @deploy
end

#forceObject

Returns the value of attribute force.



14
15
16
# File 'lib/awestruct/cli/options.rb', line 14

def force
  @force
end

#frameworkObject

Returns the value of attribute framework.



16
17
18
# File 'lib/awestruct/cli/options.rb', line 16

def framework
  @framework
end

#generateObject

Returns the value of attribute generate.



9
10
11
# File 'lib/awestruct/cli/options.rb', line 9

def generate
  @generate
end

#initObject

Returns the value of attribute init.



15
16
17
# File 'lib/awestruct/cli/options.rb', line 15

def init
  @init
end

#portObject

Returns the value of attribute port.



11
12
13
# File 'lib/awestruct/cli/options.rb', line 11

def port
  @port
end

#profileObject

Returns the value of attribute profile.



19
20
21
# File 'lib/awestruct/cli/options.rb', line 19

def profile
  @profile
end

#scaffoldObject

Returns the value of attribute scaffold.



17
18
19
# File 'lib/awestruct/cli/options.rb', line 17

def scaffold
  @scaffold
end

#scriptObject

Returns the value of attribute script.



21
22
23
# File 'lib/awestruct/cli/options.rb', line 21

def script
  @script
end

#serverObject

Returns the value of attribute server.



10
11
12
# File 'lib/awestruct/cli/options.rb', line 10

def server
  @server
end

Class Method Details

.parse!(args) ⇒ Object



39
40
41
# File 'lib/awestruct/cli/options.rb', line 39

def self.parse!(args)
  Options.new.parse! args
end

Instance Method Details

#parse!(args) ⇒ Object



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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/awestruct/cli/options.rb', line 43

def parse!(args)
  opts = OptionParser.new do |opts|
    opts.on( '-i', '--init', 'Initialize a new project in the current directory' ) do |init|
      self.init     = init
      self.generate = false
    end
    opts.on( '-f', '--framework FRAMEWORK', 'Specify a compass framework during initialization (bootstrap, blueprint, 960)' ) do |framework|
      self.framework = framework
    end
    opts.on( '--[no-]scaffold', 'Create scaffolding during initialization (default: true)' ) do |s|
      self.scaffold = s
    end
    opts.on( '--force', 'Force a regeneration' ) do |force|
      self.force = force
    end
    opts.on( '-s', '--server', 'Serve generated site' ) do |s|
      self.server = s
    end
    opts.on( '-u', '--url URL', 'Set site.base_url' ) do |url|
      self.base_url = url
    end
    opts.on( '-d', '--dev',     'Run in development mode (--auto, --server and -profile development)' ) do |url|
      self.server   = true
      self.auto     = true
      self.port     = 4242
      self.profile  = 'development'
    end

    opts.on( '-P', '--profile PROFILE', 'Specify a profile' ) do |profile|
      self.profile = profile
    end

    opts.on( '--deploy', 'Deploy site' ) do |deploy|
      self.deploy = deploy
      self.generate = false if self.generate.nil?
    end

    opts.on( '-a', '--auto', 'Auto-generate when changes are noticed' ) do |a|
      self.auto = a
    end
    opts.on( '-p', '--port PORT', Integer, 'Server port (default: 4242)' ) do |port|
      self.port = port
    end
    opts.on( '-b', '--bind ADDR', 'Server address (default: 0.0.0.0)' ) do |bind_addr|
      self.bind_addr = bind_addr
    end
    opts.on( '-g', '--[no-]generate', 'Generated site' ) do |g|
      self.generate = g
    end
    opts.on( '--run SCRIPT', 'Force a regeneration' ) do |script|
      self.script = script
    end

    opts.separator ''
    opts.separator "Common options:"

    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit
    end
  
    opts.on_tail("-v", "--version", "Display the version") do
      puts "Awestruct: #{Awestruct::VERSION}"
      puts "http://awestruct.org/"
      exit
    end
  end

  opts.parse!(args)
  self.generate = true if self.generate.nil?
  self
end