Class: Bake::VsOptions
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Parser
#add_default, #add_option, #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
|
# File 'lib/vs/options.rb', line 9
def initialize(argv)
super(argv)
@version = "2012"
@rewriteSolution = false
@roots = []
add_option(Option.new("--version",true) { |x| set_version(x) })
add_option(Option.new("--rewrite_solution",false) { set_rewrite_solution })
add_option(Option.new("-w",true) { |x| set_root(x) })
add_option(Option.new("-h",false) { usage; ExitHelper.exit(0) })
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
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/vs/options.rb', line 37
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
32
33
34
35
|
# File 'lib/vs/options.rb', line 32
def parse_options()
parse_internal(false)
@roots << Dir.pwd if @roots.length == 0
end
|
#set_rewrite_solution ⇒ Object
56
57
58
|
# File 'lib/vs/options.rb', line 56
def set_rewrite_solution
@rewriteSolution = true
end
|
#set_root(dir) ⇒ Object
60
61
62
63
64
|
# File 'lib/vs/options.rb', line 60
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
48
49
50
51
52
53
54
|
# File 'lib/vs/options.rb', line 48
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
22
23
24
25
26
27
28
29
30
|
# File 'lib/vs/options.rb', line 22
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 and 2012 (default)."
puts " --rewrite_solution Rewrites existing solution files instead of appending new projects."
puts " -h Print this help."
end
|