Skip to content

Commit 499ab29

Browse files
committed
minor bug fixes in argument handling
1 parent 52cedc9 commit 499ab29

File tree

8 files changed

+32
-7
lines changed

8 files changed

+32
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ build-iPhoneSimulator/
5050
.rvmrc
5151
/site/public
5252
/.byebug_history
53+
/.idea

.ruby-gemset

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
copper

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby-2.5.1

Gemfile.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
c66-copper (0.0.3)
4+
c66-copper (0.0.4)
55
colorize (~> 0.8)
66
ipaddress (~> 0.8)
77
json (~> 1.4)
@@ -17,8 +17,8 @@ GEM
1717
colorize (0.8.1)
1818
ffi (1.9.23)
1919
ipaddress (0.8.3)
20-
json (1.8.3)
21-
jsonpath (0.8.11)
20+
json (1.8.6)
21+
jsonpath (0.9.4)
2222
multi_json
2323
to_regexp (~> 0.2.1)
2424
listen (3.1.5)
@@ -37,7 +37,7 @@ GEM
3737
semantic (1.6.1)
3838
thor (0.20.0)
3939
to_regexp (0.2.1)
40-
treetop (1.6.9)
40+
treetop (1.6.10)
4141
polyglot (~> 0.3)
4242

4343
PLATFORMS
@@ -51,4 +51,4 @@ DEPENDENCIES
5151
rerun (~> 0.13)
5252

5353
BUNDLED WITH
54-
1.16.1
54+
1.16.4

a.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
a:
2+
b: "c"

b.rule

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rule abc warn {
2+
fetch("") -> console
3+
}

bin/copper

+18-1
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,40 @@ module Copper
3636
require 'byebug' if $debug
3737

3838
rule_file = options[:rules]
39+
if !rule_file
40+
puts "No rule file provided. Use --rule option".red
41+
exit(1)
42+
end
43+
3944
unless File.exists?(rule_file)
4045
puts "Rule file #{rule_file} not found".red
4146
exit(1)
4247
end
4348
content_file = options[:file]
49+
if !content_file
50+
puts "No config file provided. Use --file option".red
51+
exit(1)
52+
end
53+
4454
unless File.exists?(content_file)
4555
puts "Config file #{content_file} not found".red
4656
exit(1)
4757
end
4858

4959
rules = File.read(rule_file)
50-
file = ""
60+
if rules.empty?
61+
puts "Empty rules file".red
62+
exit(2)
63+
end
5164
raise ::NotImplementedError if options[:format] != 'yaml'
5265
# load the yaml file and split them into separate yamls
5366

5467
failed = false
5568
content = File.read(content_file)
69+
if content.empty?
70+
puts "Empty config file".red
71+
exit(2)
72+
end
5673
content.split('---').each_with_index do |part, idx|
5774
puts "Validating part #{idx}"
5875
file = YAML::load(part)

lib/copper/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Copper
2-
VERSION = '0.0.4'
2+
VERSION = '0.0.5'
33
COPYRIGHT_MESSAGE = "(c) 2018 Cloud66 Inc."
44
APP_NAME = 'Copper'
55
end

0 commit comments

Comments
 (0)