Modified a few things:
- Finished implementing relative date parsing and migrated date parsing from Flag(T) to it's own dedicated module. Additionally added a the ability to do "recursive" relative operations for time searching. - Additionally made a Struct & Enum for containing relative operations around dates. - Added additional checks in App & CommandNode(T) around checking env_vars of flags & checking for duplicate commands - Added a CommandMeta record to contain the classname of the CommandNode(T) - Seperated out all of the monolitic files (command_node.cr & file.cr). Moved the base classes and records into their own files in the dir with the same name of their generic counterparts. - Fixed a number of macro related bugs around Command.argument & CliGen.add_global_flag - My ass hurts from sitting here for hours and doing these changes and arguing with claude over what needs to be done. Fun tho.
This commit is contained in:
+5
-26
@@ -1,6 +1,5 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright 2026 Tristan Ancelet
|
||||
|
||||
require "./cligen/exceptions"
|
||||
require "./cligen/coercable"
|
||||
@@ -9,6 +8,7 @@ require "./cligen/annotations"
|
||||
require "./cligen/format"
|
||||
require "./cligen/regex"
|
||||
require "./cligen/flag"
|
||||
require "./cligen/timeparse"
|
||||
require "./cligen/command"
|
||||
require "./cligen/command_node"
|
||||
require "./cligen/app"
|
||||
@@ -16,32 +16,11 @@ require "./cligen/app"
|
||||
module CliGen
|
||||
VERSION = "0.1.0"
|
||||
|
||||
APPNAME = File.basename(PROGRAM_NAME)
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user