From b7564637cae8d515bffc6d0639266ebf9af48a49 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 5 Apr 2018 16:28:34 -0400 Subject: [PATCH] add main cxl.rb, Cxl::VERSION, and initial CLI processing --- bin/cxlc | 2 +- lib/cxl/cxl/lib/cxl.rb | 2 ++ lib/cxl/cxl/lib/cxl/cli.rb | 25 ++++++++++++++++++++++++- lib/cxl/cxl/lib/cxl/version.rb | 3 +++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 lib/cxl/cxl/lib/cxl.rb create mode 100644 lib/cxl/cxl/lib/cxl/version.rb diff --git a/bin/cxlc b/bin/cxlc index c4855d2..b7e78e0 100755 --- a/bin/cxlc +++ b/bin/cxlc @@ -5,6 +5,6 @@ $LOAD_PATH << "#{lib_dir}/cxl/lib" $LOAD_PATH << "#{lib_dir}/yawpa/lib" $LOAD_PATH << "#{lib_dir}/whittle/lib" -require "cxl/cli" +require "cxl" exit(Cxl::Cli.run(ARGV.dup)) diff --git a/lib/cxl/cxl/lib/cxl.rb b/lib/cxl/cxl/lib/cxl.rb new file mode 100644 index 0000000..8eee01b --- /dev/null +++ b/lib/cxl/cxl/lib/cxl.rb @@ -0,0 +1,2 @@ +require "cxl/cli" +require "cxl/version" diff --git a/lib/cxl/cxl/lib/cxl/cli.rb b/lib/cxl/cxl/lib/cxl/cli.rb index 6178398..bb0b2c2 100644 --- a/lib/cxl/cxl/lib/cxl/cli.rb +++ b/lib/cxl/cxl/lib/cxl/cli.rb @@ -2,10 +2,33 @@ module Cxl class Cli class << self + HELP_TEXT = < -- + Options: + --version show version and exit + --help, -h show this help and exit + -c compile only (no link) + -o OUTPUT send output to file OUTPUT +EOF + def run(params) require "yawpa" - puts "Coming soon..." + options = { + version: {}, + help: {short: "h"}, + compile_only: {short: "c"}, + output: {short: "o", nargs: 1}, + } + opts, args = Yawpa.parse(params, options, posix_order: true) + if opts[:version] + puts "clxc, version #{Cxl::VERSION}" + return 0 + end + if opts[:help] + puts HELP_TEXT + return 0 + end 0 end diff --git a/lib/cxl/cxl/lib/cxl/version.rb b/lib/cxl/cxl/lib/cxl/version.rb new file mode 100644 index 0000000..ef75359 --- /dev/null +++ b/lib/cxl/cxl/lib/cxl/version.rb @@ -0,0 +1,3 @@ +module Cxl + VERSION = "0.0.1" +end