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
|
# File 'lib/octorule/cli.rb', line 17
def run
parse_options
unless @options[:org]
warn "Error: Organization name is required. Use --org or set GITHUB_ORG environment variable"
exit 1
end
unless @options[:settings]
warn "Error: Settings file is required. Use --settings"
exit 1
end
token = @options[:token] || ENV["GITHUB_TOKEN"]
unless token
warn "Error: GitHub token is required. Use --token or set GITHUB_TOKEN environment variable"
exit 1
end
settings = load_settings(@options[:settings])
if settings.empty?
warn "Error: Settings file is empty"
exit 1
end
filters = {
name_pattern: @options[:name_pattern],
label: @options[:label],
language: @options[:language],
fork: @options[:fork]
}
client = Octokit::Client.new(access_token: token, api_endpoint: @options[:base_url])
syncer = Syncer.new(client, @options[:org], settings, filters, @options[:dry_run])
syncer.sync
rescue StandardError => e
warn "Error: #{e.message}"
exit 1
end
|