43 lines
1.1 KiB
Crystal
43 lines
1.1 KiB
Crystal
require "./cligen/coercable"
|
|
require "./cligen/parsable"
|
|
require "./cligen/annotations"
|
|
require "./cligen/format"
|
|
require "./cligen/regex"
|
|
require "./cligen/flag"
|
|
require "./cligen/command"
|
|
require "./cligen/command_node"
|
|
require "./cligen/app"
|
|
|
|
module CliGen
|
|
VERSION = "0.1.0"
|
|
|
|
macro override_help_template(filepath)
|
|
{% raise "ERROR : CliGen.override_help_template : File(#{filepath}) doesn't exist" unless file_exists?(filepath) %}
|
|
CliGen::HELP_OVERRIDE_TEMPLATE = {{`readlink -f #{filepath}`.strip.stringify}}
|
|
end
|
|
|
|
APPNAME = File.basename(PROGRAM_NAME)
|
|
|
|
record AdditionalDefaultFlag,
|
|
short : String,
|
|
long : String,
|
|
description : String,
|
|
work : String ->
|
|
|
|
ADDITIONAL_DEFAULT_FLAGS = [] of AdditionalDefaultFlag
|
|
|
|
def self.add_default_flag(short : String = "", long : String = "", description : String = "", &work : String -> )
|
|
raise "ERROR : add_default_flag : You must provide a description" if description.empty?
|
|
ADDITIONAL_DEFAULT_FLAGS << AdditionalDefaultFlag.new(
|
|
short: short,
|
|
long: long,
|
|
description: description,
|
|
work: work
|
|
)
|
|
end
|
|
|
|
annotation DefaultFlag
|
|
end
|
|
end
|
|
|