4
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/auto_tagger/options.rb', line 4
def self.from_command_line(args)
options = {}
args.extend(::OptionParser::Arguable)
args.options do |opts|
opts.banner = [
"",
" USAGE: autotag command [stage] [options]",
"",
" Examples:",
"",
" autotag help",
" autotag version",
" autotag create demo",
" autotag create demo .",
" autotag create demo ../",
" autotag create ci /data/myrepo",
" autotag create ci /data/myrepo --fetch-refs=false --push-refs=false",
" autotag create ci /data/myrepo --offline",
" autotag create ci /data/myrepo --dry-run",
"",
" autotag list demo",
"",
" autotag cleanup demo --refs-to-keep=2",
" autotag cleanup demo --refs-to-keep=2",
" autotag delete_locally demo",
" autotag delete_on_remote demo",
"",
"",
].join("\n")
common_options(opts, options)
opts.on("--opts-file OPTS_FILE",
"full path to the opts file",
"Defaults to working directory's .auto_tagger file",
"Example: /usr/local/.auto_tagger") do |o|
options[:opts_file] = o
end
opts.on_tail("-h", "--help", "-?", "You're looking at it.") do
options[:show_help] = true
options[:command] = :help
end
opts.on_tail("--version", "-v", "Show version") do
options[:show_version] = true
options[:command] = :version
end
end.parse!
case args.first.to_s.downcase
when "config"
options[:command] = :config
when "version"
options[:show_version] = true
options[:command] = :version
when "help"
options[:show_help] = true
options[:help_text] = args.options.help
options[:command] = :help
when ""
if options[:show_version]
options[:command] = :version
else
options[:show_help] = true
options[:help_text] = args.options.help
options[:command] = :help
end
when "cleanup"
options[:command] = :cleanup
options[:stage] = args[1]
when "delete_locally"
options[:command] = :delete_locally
options[:stage] = args[1]
when "delete_on_remote"
options[:command] = :delete_on_remote
options[:stage] = args[1]
when "list"
options[:command] = :list
options[:stage] = args[1]
when "create"
options[:command] = :create
options[:stage] = args[1]
options[:path] = args[2]
else
if options[:command].nil?
options[:command] = :create options[:deprecated] = true
options[:stage] = args[0]
options[:path] = args[1]
end
end
options
end
|