Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 6812820

Browse files
committed
Handle unknown options
1 parent ca97d3e commit 6812820

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

wpxf.rb

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,40 @@
55
require 'cli/console'
66
require 'slop'
77

8-
Slop.parse do |o|
9-
o.on '--update', 'check for updates' do
10-
current_version = File.read('VERSION').strip
8+
begin
9+
Slop.parse do |o|
10+
o.on '--update', 'check for updates' do
11+
current_version = File.read('VERSION').strip
1112

12-
updater = Wpxf::GitHubUpdater.new
13-
update = updater.get_update(current_version)
13+
updater = Wpxf::GitHubUpdater.new
14+
update = updater.get_update(current_version)
1415

15-
if update.nil?
16-
puts 'No updates available'
17-
exit
18-
end
16+
if update.nil?
17+
puts 'No updates available'
18+
exit
19+
end
1920

20-
puts 'A new update is available!'
21-
puts
22-
puts '-- Release Notes --'
23-
puts update[:release_notes]
24-
puts
25-
puts "Downloading latest update (#{update[:release_name]})..."
26-
updater.download_and_apply_update(update[:zip_url])
21+
puts 'A new update is available!'
22+
puts
23+
puts '-- Release Notes --'
24+
puts update[:release_notes]
25+
puts
26+
puts "Downloading latest update (#{update[:release_name]})..."
27+
updater.download_and_apply_update(update[:zip_url])
2728

28-
puts 'Update finished! Make sure to run "bundle install" in the WPXF directory.'
29-
puts
30-
exit
31-
end
29+
puts 'Update finished! Make sure to run "bundle install" in the WPXF directory.'
30+
puts
31+
exit
32+
end
3233

33-
o.on '--version', 'print the version' do
34-
puts File.read('VERSION').strip
35-
exit
34+
o.on '--version', 'print the version' do
35+
puts File.read('VERSION').strip
36+
exit
37+
end
3638
end
39+
rescue Slop::UnknownOption => e
40+
puts e.message
41+
exit
3742
end
3843

3944
puts ' _'

0 commit comments

Comments
 (0)