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
36
37
38
39
40
41
|
# File 'lib/potatochop/cli_parser.rb', line 5
def self.parse(args)
options = {
:interface => nil,
:interface_class => Potatochop::FileSystemInterface,
:mockups_path => '.',
:gh_options => {}
}
opts = OptionParser.new do |opts|
opts.banner = "Usage: potatochop [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on("-i", "--interface [INTERFACE]", "How to find the files to serve (possible options are 'local' and 'github')") do |interface|
if interface == 'github'
options[:interface_class] = Potatochop::GithubInterface
end
end
opts.on("-d", "--mockups [PATH]", "Path to the mockups folder you want to serve") do |wd|
options[:mockups_path] = wd
end
opts.on("--repo [GITHUB REPOSITORY]", "username/reponame on GitHub") do |repo|
options[:mockups_path] = repo
end
opts.on("--token [GITHUB ACCESS TOKEN]", "GitHub access token (needed to access private repositories)") do |token|
options[:gh_options][:access_token] = token
end
end
opts.parse!(args)
options[:interface] = options[:interface_class].send(:new, options[:mockups_path], options[:gh_options])
options
end
|