Testing
This commit is contained in:
@@ -14,8 +14,8 @@ module CliGen
|
|||||||
|
|
||||||
ADDITIONAL_DEFAULT_FLAGS = [] of AdditionalDefaultFlag
|
ADDITIONAL_DEFAULT_FLAGS = [] of AdditionalDefaultFlag
|
||||||
|
|
||||||
def self.add_default_flag(short : String, long : String, description : String, &work : String -> )
|
def self.add_default_flag(short : String = "", long : String = "", description : String = "", &work : String -> )
|
||||||
raise "ERROR : add_default_flag : You must provide a description" unless description
|
raise "ERROR : add_default_flag : You must provide a description" if description.empty?
|
||||||
ADDITIONAL_DEFAULT_FLAGS << AdditionalDefaultFlag.new(
|
ADDITIONAL_DEFAULT_FLAGS << AdditionalDefaultFlag.new(
|
||||||
short: short,
|
short: short,
|
||||||
long: long,
|
long: long,
|
||||||
@@ -64,7 +64,13 @@ module CliGen
|
|||||||
}
|
}
|
||||||
|
|
||||||
CliGen::ADDITIONAL_DEFAULT_FLAGS.each do |flag|
|
CliGen::ADDITIONAL_DEFAULT_FLAGS.each do |flag|
|
||||||
|
if [ flag.short, flag.long ].all?(&.!= "")
|
||||||
{{parser}}.on(flag.short, flag.long, flag.description){|var| flag.work.call(var) }
|
{{parser}}.on(flag.short, flag.long, flag.description){|var| flag.work.call(var) }
|
||||||
|
elsif flag.short != ""
|
||||||
|
{{parser}}.on(flag.short, flag.description){|var| flag.work.call(var) }
|
||||||
|
elsif flag.long != ""
|
||||||
|
{{parser}}.on(flag.long, flag.description){|var| flag.work.call(var) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user