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
42
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
|
# File 'lib/piston/cli.rb', line 8
def self.start(args=ARGV)
options = {:lock => false, :force => false, :dry_run => false, :quiet => false, :verbose => 0}
opts = OptionParser.new do |opts|
opts.banner = "Usage: piston COMMAND [options]"
opts.version = Piston::VERSION::STRING
opts.on("-r", "--revision REVISION", "Revision to operate on") do |r|
options[:revision] = r.to_i
end
opts.on("--commit TREEISH", "Commit to operate on") do |c|
options[:commit] = c
end
opts.on("--repository-type TYPE", [:git, :svn], "Force selection of a repository handler (git or svn)") do |type|
options[:repository_type] = type
end
opts.on("--lock", "Lock down the revision against mass-updates") do
options[:lock] = true
end
opts.on("--show-updates", "Query the remote repository for out-of-dateness information") do
options[:show_updates] = true
end
opts.on("--force", "Force the operation to go ahead") do
options[:force] = true
end
opts.on("--dry-run", "Run but do not change anything") do
options[:dry_run] = true
end
opts.on("-q", "--quiet", "Operate silently") do
options[:quiet] = true
end
opts.on("-v", "--verbose [LEVEL]", ("0".."5").to_a, "Increase verbosity (default 0)") do |level|
options[:verbose] = level.to_i || 1
end
end
opts.parse!(args)
if args.empty?
puts opts.help
exit 0
end
if options.has_key?(:revision) && options.has_key?(:commit) then
raise ArgumentError, "Only one of --revision or --commit can be given. Received both."
end
configure_logging(options)
command = Piston::Commands.const_get(args.shift.camelize).new(options)
command.start(*args)
end
|