From feeed2306c4bc703efdf599ce4b19943206b3703 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Mon, 1 Mar 2021 16:06:35 +0100 Subject: [PATCH] read-spec tool --- read-spec.cr | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 read-spec.cr diff --git a/read-spec.cr b/read-spec.cr new file mode 100644 index 0000000..37bdd63 --- /dev/null +++ b/read-spec.cr @@ -0,0 +1,27 @@ +require "option_parser" +require "colorize" +require "./src/specparser" + +recipe_file_name = "some-non-existant-file" + +OptionParser.parse do |parser| + parser.on "-f file", "--file file", "File to parse." do |f| + recipe_file_name = f + end + + parser.on "-h", "--help", "Show this help" do + puts parser + exit 0 + end +end + + +options = Hash(String,String).new +options["someoptionexample"] = "option" + +begin + specs = SpecParser.parse_file recipe_file_name, options + pp! specs +rescue e + STDERR.puts "#{e}".colorize(:red).bright +end