add main cxl.rb, Cxl::VERSION, and initial CLI processing

This commit is contained in:
Josh Holtrop 2018-04-05 16:28:34 -04:00
parent 04d7558579
commit b7564637ca
4 changed files with 30 additions and 2 deletions

View File

@ -5,6 +5,6 @@ $LOAD_PATH << "#{lib_dir}/cxl/lib"
$LOAD_PATH << "#{lib_dir}/yawpa/lib" $LOAD_PATH << "#{lib_dir}/yawpa/lib"
$LOAD_PATH << "#{lib_dir}/whittle/lib" $LOAD_PATH << "#{lib_dir}/whittle/lib"
require "cxl/cli" require "cxl"
exit(Cxl::Cli.run(ARGV.dup)) exit(Cxl::Cli.run(ARGV.dup))

2
lib/cxl/cxl/lib/cxl.rb Normal file
View File

@ -0,0 +1,2 @@
require "cxl/cli"
require "cxl/version"

View File

@ -2,10 +2,33 @@ module Cxl
class Cli class Cli
class << self class << self
HELP_TEXT = <<EOF
Usage: clxc [options] <input-files...> -- <C-compiler-flags>
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) def run(params)
require "yawpa" 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 0
end end

View File

@ -0,0 +1,3 @@
module Cxl
VERSION = "0.0.1"
end