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
|
# File 'lib/sync_github_forks/cli.rb', line 39
def self.start(args = ARGV)
options = OpenStruct.new
options.config_file = nil
options.github_token = nil
OptionParser.new do |opts|
opts.on('-c', '--config FILE', 'Use FILE as the configuration file') do |file|
options.config_file = file
end
opts.on('-t', '--github_token TOKEN', 'Your GitHub Access Token',
'Default: GITHUB_ACCESS_TOKEN environment variable'
) do |token|
options.github_token = token
end
opts.on('-h', '--help', 'This help message') do
puts opts
exit
end
end
unless options.config_file
options.config_file = find_config
unless options.config_file
$stderr.puts("ERROR: Could not find configuration file")
exit 1
end
end
begin
options.config = YAML.load_file(options.config_file)
rescue StandardError
$stderr.puts("ERROR: Config '#{options.config_file}' is not a valid YAML file")
exit 1
end
unless options.github_token
options.github_token = ENV['GITHUB_ACCESS_TOKEN']
end
unless options.github_token
$stderr.puts('ERROR: You must set GITHUB_ACCESS_TOKEN')
exit 1
end
SyncGithubForks::Ctrl.sync(options)
return 0
end
|