Skip to content

Commit

Permalink
minor bug fixes in argument handling
Browse files Browse the repository at this point in the history
  • Loading branch information
khash committed Aug 31, 2018
1 parent 52cedc9 commit 499ab29
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ build-iPhoneSimulator/
.rvmrc
/site/public
/.byebug_history
/.idea
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
copper
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.5.1
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
c66-copper (0.0.3)
c66-copper (0.0.4)
colorize (~> 0.8)
ipaddress (~> 0.8)
json (~> 1.4)
Expand All @@ -17,8 +17,8 @@ GEM
colorize (0.8.1)
ffi (1.9.23)
ipaddress (0.8.3)
json (1.8.3)
jsonpath (0.8.11)
json (1.8.6)
jsonpath (0.9.4)
multi_json
to_regexp (~> 0.2.1)
listen (3.1.5)
Expand All @@ -37,7 +37,7 @@ GEM
semantic (1.6.1)
thor (0.20.0)
to_regexp (0.2.1)
treetop (1.6.9)
treetop (1.6.10)
polyglot (~> 0.3)

PLATFORMS
Expand All @@ -51,4 +51,4 @@ DEPENDENCIES
rerun (~> 0.13)

BUNDLED WITH
1.16.1
1.16.4
2 changes: 2 additions & 0 deletions a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a:
b: "c"
3 changes: 3 additions & 0 deletions b.rule
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rule abc warn {
fetch("") -> console
}
19 changes: 18 additions & 1 deletion bin/copper
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,40 @@ module Copper
require 'byebug' if $debug

rule_file = options[:rules]
if !rule_file
puts "No rule file provided. Use --rule option".red
exit(1)
end

unless File.exists?(rule_file)
puts "Rule file #{rule_file} not found".red
exit(1)
end
content_file = options[:file]
if !content_file
puts "No config file provided. Use --file option".red
exit(1)
end

unless File.exists?(content_file)
puts "Config file #{content_file} not found".red
exit(1)
end

rules = File.read(rule_file)
file = ""
if rules.empty?
puts "Empty rules file".red
exit(2)
end
raise ::NotImplementedError if options[:format] != 'yaml'
# load the yaml file and split them into separate yamls

failed = false
content = File.read(content_file)
if content.empty?
puts "Empty config file".red
exit(2)
end
content.split('---').each_with_index do |part, idx|
puts "Validating part #{idx}"
file = YAML::load(part)
Expand Down
2 changes: 1 addition & 1 deletion lib/copper/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Copper
VERSION = '0.0.4'
VERSION = '0.0.5'
COPYRIGHT_MESSAGE = "(c) 2018 Cloud66 Inc."
APP_NAME = 'Copper'
end

0 comments on commit 499ab29

Please sign in to comment.