Class: Bake::VsOptions
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Parser
#add_option, #get_block, #parse_internal
Constructor Details
#initialize(argv) ⇒ VsOptions
Returns a new instance of VsOptions.
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/vs/options.rb', line 9
def initialize(argv)
super(argv)
@version = "2012"
@rewriteSolution = false
@roots = []
add_option(["--version" ], lambda { |x| set_version(x) })
add_option(["--rewrite", "--rewrite_solution"], lambda { set_rewrite_solution })
add_option(["-w", ], lambda { |x| set_root(x) })
add_option(["-h", "--help" ], lambda { usage; ExitHelper.exit(0) })
add_option(["" ], lambda { |x| puts "Error: invalid argument #{x}"; usage; ExitHelper.exit(1) })
end
|
Instance Attribute Details
#rewriteSolution ⇒ Object
Returns the value of attribute rewriteSolution.
7
8
9
|
# File 'lib/vs/options.rb', line 7
def rewriteSolution
@rewriteSolution
end
|
#roots ⇒ Object
Returns the value of attribute roots.
7
8
9
|
# File 'lib/vs/options.rb', line 7
def roots
@roots
end
|
#version ⇒ Object
Returns the value of attribute version.
7
8
9
|
# File 'lib/vs/options.rb', line 7
def version
@version
end
|
Instance Method Details
#check_valid_dir(dir) ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/vs/options.rb', line 38
def check_valid_dir(dir)
if not File.exists?(dir)
puts "Error: Directory #{dir} does not exist"
ExitHelper.exit(1)
end
if not File.directory?(dir)
puts "Error: #{dir} is not a directory"
ExitHelper.exit(1)
end
end
|
#parse_options ⇒ Object
33
34
35
36
|
# File 'lib/vs/options.rb', line 33
def parse_options()
parse_internal()
@roots << Dir.pwd if @roots.length == 0
end
|
#set_rewrite_solution ⇒ Object
57
58
59
|
# File 'lib/vs/options.rb', line 57
def set_rewrite_solution
@rewriteSolution = true
end
|
#set_root(dir) ⇒ Object
61
62
63
64
65
|
# File 'lib/vs/options.rb', line 61
def set_root(dir)
check_valid_dir(dir)
r = File.expand_path(dir.gsub(/[\\]/,'/'))
@roots << r if not @roots.include?r
end
|
#set_version(v) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/vs/options.rb', line 49
def set_version(v)
if v != "2010" and v != "2012" and v != "2013"
puts "Error: version must be '2010', '2012' or '2013'"
ExitHelper.exit(1)
end
@version = v
end
|
#usage ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/vs/options.rb', line 23
def usage
puts "\nUsage: createVSProjects [options]"
puts " -w <root> Add a workspace root. Default is current directory."
puts " This option can be used at multiple times."
puts " Solution files will be created in the first root directory."
puts " --version <year> Visual Studio version. Currently supported: 2010, 2012 (default) and 2013."
puts " --rewrite Rewrites existing solution files instead of appending new projects."
puts " -h, --help Print this help."
end
|