Class: Behave::CLI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



124
125
126
127
# File 'lib/behave.rb', line 124

def initialize(args)
  attrs = parse(args)
  @fd = Behave::FeatureDownloader.new(attrs)
end

Instance Attribute Details

#fdObject

Returns the value of attribute fd.



122
123
124
# File 'lib/behave.rb', line 122

def fd
  @fd
end

Instance Method Details

#parse(args) ⇒ Object



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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/behave.rb', line 129

def parse(args)
  map = {}
  map["dir"] = "./"

  opts = OptionParser.new do |opts|
    opts.banner = "Usage: behave [options]"

    opts.separator ""
    opts.separator "Specific options:"

    opts.on("-h", "--host HOST",
            "Host URI for Jira installation") do |host|
      host << '/' unless host[-1,1] == '/'
      map["host"] = host
    end

    opts.on("-u", "--user USER",
            "User with Behave rights on project") do |user|
      map["user"] = user
    end

    opts.on("-p", "--pass PASS",
            "Password of user") do |pass|
      map["pass"] = pass
    end

    opts.on("-k", "--key KEY",
            "Project key to download features from") do |key|
      map["key"] = key
    end

    opts.on("-d", "--directory [DIR]",
            "Specify output directory (default 'features')") do |dir|
      dir << '/' unless dir[-1,1] == '/'
      map["dir"] = dir
    end

    opts.on("-m", "--manual",
            "Include manual tagged scenarios in download") do
      map["manual"] = true
    end

    opts.on("--proxy PROXY_URL",
            "Pass requests through a PROXY_URL") do |proxy|
      map["proxy"] = proxy
    end

    opts.on("--bypass-ssl",
            "Bypass SSL certificate checking") do
      map["bypass_ssl"] = true
    end

    opts.on_tail("--help", "Show this message") do
      puts opts
      exit
    end

    opts.on_tail("--version", "Show version") do
      puts Behave::VERSION
      exit
    end
  end

  opts.parse!(args)

  return map

end