Releases: darvil82/lanat
Releases · darvil82/lanat
Version 1.2.0
Version 1.1.0 - Automatic enum inference
Features
- Allow enums to be inferred automatically.
- New predicate infers for
ArgumentTypeInfer
. Slower to lookup when inferring, but allow for more precise control. (Used for inferring enums) - Improve error messages for
SingleValueListArgumentType
. Closes #24 - Argument types can now set the initial value at any point (not limited to construction).
Fixes
SingleValueListArgumentType
allowing duplicates and empty values upon definition.
Version 1.0.0 - First stable release
Documentation now available!
Check out the complete documentation at https://darvil82.github.io/lanat-docs
Features
-
Argument types
- Add
ActionArgumentType
. This is the oldBooleanArgumentType
. BooleanArgumentType
can now receive values as well. Those beingtrue
,false
,yes
,no
, etc.TupleArgumentType
is no longer abstract and does not take a default value in its constructor now. Instead takes another argument type instance. The tuple argument type can now work with any argument type passed to it.- Change
forEachArgValue()
togetArgValuesStream()
. - Add
getRequiredUsageCount()
toParseable
. - Add default implementation to
getRequiredUsageCount
andgetRequiredArgValueCount
inParseable
. TryParseArgumentType
will now try to infer the type first if possible.- Make
Parseable
a functional interface. - Add
SimpleArgumentType
. Allows to create argument types with a builder pattern. Implements the aforementionedBuilder
. - Add
OptListArgumentType
. Similar toEnumArgumentType
, but accepts a list of all possible strings the user can introduce. - Add
SingleValueListArgumentType
abstract class.EnumArgumentType
andOptListArgumentType
both inherit this. - Add constructor to
ArgumentType
to pass aParseable
to check restrictions on. - Add
unregisterSubType()
toArgumentType
. - Add
unregister
toArgumentTypeInfer
. - Add
ArgumentTypeError
. - Argument types now throw
ArgumentTypeError
instead ofCustomErrorImpl
.
- Add
-
AfterParseOptions
- Actions are now supplied by using the
withActions()
method, which accepts a callback defining the actions chain. - Actions are now run when a terminating method is called. These are either
getResult()
orinto()
. This ensures other callbacks defined are invoked at the correct time. - The default actions chain is now
DEFAULT_ACTIONS
.public static final Consumer<@NotNull AfterParseActions> DEFAULT_ACTIONS = a -> a .printHelpIfNoInput() .exitIfNoInput() .printErrors() .exitIfErrors();
- Add
hasReceivedInput()
to check if the program received any input at all.
- Actions are now supplied by using the
-
Arguments
- Add
visible
property. This allows to hide this argument from the help message. Use thesetVisible
method. This property has been added toArgumentBuilder
and theArgument.Define
annotation as well. - Remove
Argument.createOfBoolType()
in favor of newArgument.createOfActionType()
. - Arguments are now represented in help with a single prefix.
- Positional arguments will now be the first to appear in the help synopsis representation.
- Improve how arguments appear in help descriptions. Multiple names are now shown in a less confusing manner.
- Add
isOrphan()
. Returnstrue
if this argument doesn't belong to any command or group. - Add
removePrefix()
static method. - When specifying the argument type upon argument creation, a
Builder<ArgumentType>
may also be specified instead.
- Add
-
Commands
- Add
int
parameter toaddHelpArgument()
andaddVersionArgument()
to specify the exit code upon quitting. - Add
onUsed
callback. Can be set withsetOnUsedCallback()
. This callback is functionally equivalent toCommandTemplate#onUsed
. Command#getParseResult
will return cached results if called multiple times.- Templates
- Greatly improved error messages when creating arguments from command template fields.
- Groups can now be defined in command templates by setting the
group
value in theArgument.Define
annotation. Multiple argument fields defined with the samegroup
value will be added to a group with that name. - Add
argWithType
helper method toCommandBuildHelper
to remove the need to specify type parameters while setting the type. - Add
CommandTemplate.Default.WithVerbose
, which includes averbose
counter argument. - Add error to make it clear the user must manually provide the argument type when using
Optional
in the command template field. onUsed
now received theParseResult
instance as a parameter.
- Add
-
Misc
- Now supports the NO-COLOR environment variable.
com.darvil:utils
andcom.darvil:terminal-text-formatter
are now both API dependencies, thus the user will no longer have to manually install them.- Add
CLInput#fromFile
andCLInput#fromStandardInput
. - Add
ArgumentParser#parseFromInto
overload that takesString[]
for ease of use. - Argument group help descriptions now always show arguments even if these don't have any description set. Applies to nested groups.
- Greatly improve error messages when there is a failure when inferring types.
- Parsing a help description tag like
<tag=>
will now be considered invalid syntax. - Add
Builder<T>
interface. Custom builders may be made implementing this interface.ArgumentBuilder
now implementsBuilder
.
ArgumentAdder#addArgument
now accepts a genericBuilder
instance too.- Improve
toString
representation of arguments and commands and groups. - Add
setNames
method toMultipleNamesAndDescription
. Implementors now only implement this method.addNames
has a default implementation now. - Add
unregister
method toTag
. - Negative margin and indent values are no longer silently capped to 0 when negative. Now throws.
- Improve
ColorTag
syntax. Now accepts true color values with thecolor_name|#rrggbb|r,g,b
syntax. - Add
DefaultValueTag
for arguments. - Errors may now choose to remove other errors by overriding the
shouldRemoveOther()
method inError
.- A
RequiredArgumentNotUsedError
will no longer appear if anIncorrectValueNumberError
is present for the same argument. - An
UnmatchedTokenError
will no longer appear if aSimilarArgumentError
is present for the same token index.
- A
- Add
representationColor
toArgumentBuilder
. - When mentioning elements in a a command (such as arguments), errors will now use their actual help representation instead of just the name.
- Add
SimpleError
. - Commands may now contain
Error<?>
instead of being restricted toCustomError
(now removed).
Fixes
- Fix help message not appearing if no input was provided. (Default actions)
- Fix index out of bounds exception being thrown when the last character in the input is a backslash.
- Optimized initialization of many internal lists that most of the time aren't filled that much.
- Fix description of commands always showing up in the help message.
- Fix crash when attempting to add arguments to a group that has already been added to a command.
- Fix argument group descriptions showing up if no arguments inside it have descriptions.
- Fix crash in some cases when registering a group.
- Fix default value of arguments not properly being used in some cases.
- Fix
KeyValuesArgumentType
adding null values when keys fail to parse. ArgumentTypeInfer
can no longer be instantiated.- Fix incorrect report for the
SimilarArgument
parse error. - Fix an error when attempting to close a string inside a tuple.
- Optimize
Argument#checkMatch
to not perform many useless string concatenations. - Fix
Tag#register
method allowing to replace previous entries. - Fix
DescriptionParser
not properly parsing backslashes if no tags are present. - Fix
DescriptionParser
throwingIllegalArgumentException
instead ofMalformedTagException
in a case. - Fix
DescriptionParser
not throwing aMalformedTagException
if a tag is blank. - Fix argument descriptions showing up as "null" if none had descriptions set.
- Tag name and value not being trimmed correctly.
- Fix being possible to use arguments when a unique argument was used. Added new parse error for this.
- Fix
LinkTag
giving incorrect representations for groups. - Fix terminal sequences not resetting properly on descriptions.
- Fix
HelpFormatter#setIndentSize
,getIndentSize
and all its usages not being static. - Fix
CommandTemplate#afterInit
only accepting equal types, but not assignable toCommand
. (Can now acceptArgumentParser
) - Fix program details layout item missing an indentation in the help message.
ArgumentTypeInfer
allowing to set infer forOptional
.- Fix help message printing extra line feed.
CLInput#fromSystemProperty
not working properly when no input is passed in.- Argument types allowing to throw errors before parsing started, potentially crashing.
Refactors
- Move
AfterParseOptions
to its own class. - Rename
Argument#argType
toArgument#type
. Applies toArgumentBuilder
andArgument.Define
as well. - Remove
Argument.create()
overloads involvingchar
. - Commands no longer have the ability to define the tuple char to use. This is now globally defined in
TupleChar#current
. - Move
CallbacksInvocationOption
intoCommand
. - Change all
\n
usages toSystem#lineSeparator()
to improve compatibility. PrefixChar
is now an enum. It is no longer allowed to use any character for a prefix. TheArgument.Define
annotation now uses this enum for the prefixChar value.- The default prefix may now be set with
PrefixChar.setDefaultPrefix()
. - Remove duplicated code in
ArgumentGroupRepr
. - Reorganized many files and code.
- Argument groups are now added differently. The group hierarchy is linked right before parsing now.
- Remove
MultipleNumbersArgumentType
andMultipleStringsArgumentType
. No longer needed with the newTupleArgumentType
. - Rename "license" to "program details" (help message).
- Rename "args" to "values" in argument types.
- Remove unnecessary anonymous subclassing in some places.
- Remove
ArgumentType#setValue()
. - Rename
ErrorsContainer
,ErrorsCollector
andErrorsContainerImpl
to singularError
. (eg, ErrorContain...
Version 0.3.0
Features
- Rename
ParsedArguments
toParseResult
. - Add more javadocs and improved some other.
- Add
onValuesReceived()
toCommandTemplate
. This is a method that an inheritor may override. - Add
getParseResult()
toCommandTemplate
. - Add
wasUsed()
,getCommand()
toCommandTemplate
andParseResult
. ParseResult#getSubResult()
now returns a non-nullable value. (Now throws if no command was found)- Add
getUsedResults()
toParseResultRoot
.
Fixes
- Tiny fix on the javadoc of
ArgumentGroup
. - Some other javadoc fixes.
Version 0.2.1
- "Exclusive" groups are now named "Restricted".
- Fix restricted groups incorrectly throwing errors for usage violations that do not occur.
Version 0.2.0
Now available on a repsy repository!
Lanat may now be installed by adding the corresponding repository and dependency, as explained in the README.md. (The github package is still available)
Features
- Add default
isRoot
method toParentElementGetter
. - Default
help
andversion
arguments now close the program when used. - Make errors of description tags more clear.
- Add
SpaceRequired
error when tokenizing. Thrown when two tokens require a space between them. - Tokenizer error formatter now properly highlights input characters. For instance; a string left open is now correctly highlighted from the start of the string open char to the end of the input.
Fixes
- Errors not being properly cleared up when resetting.
CommandAdder
hasCommand
andgetCommand
methods not returning a sub-command in some cases.- Possible to set invalid names to description tags.
- Tokenizer errors not properly highlighting the errors in some cases.
- Possible to register an argument subtype that was already registered to another argument type.
- Errors dispatched to parent argument types being saved on both the parent and child.
- Parsing occurring even if tokenization failed (again).
- Errors not being cached after the first call to
ArgumentParser#getErrors
. - Unnecessary checks in error handling methods of
Argument
. - Tuple characters changes not being reflected on the tokenization state.
- Tokenization not being skipped when a blank string is passed.
- Strings allowing no spaces after or before them.
- Tuples allowing no spaces after them.
- Tokenizer not recognizing other whitespace characters than space.
- Checking for similar arguments being done on the tokenization state (rather than parse).
TryParseArgumentType
throwing an incorrect message for an error.
Misc
- Add lots of javadocs.
- Remove
Argument#isHelpArgument
. - Small tweaks to some
ArgumentType
s. - Separated unrelated code into separate libraries (#14):
- For misc utilities (https://github.com/DarviL82/java-utils). This change removes the next classes from the project:
LoopPool
ModifyRecord
MultiComparator
Pair
Random
Range
UtlReflection
UtlString
- For terminal text formatting (https://github.com/DarviL82/java-terminal-text-formatter). This change removes the next classes from the project:
Color
FormatOption
TextFormatter
- For misc utilities (https://github.com/DarviL82/java-utils). This change removes the next classes from the project:
- Refactors:
Tokenizer
,Parser
andErrorHandler
(now calledErrorsCollector
) (#13). Handling of errors no longer uses reflection. Error handling is now more flexible and simple.- Parsing of sub-commands has been greatly improved. Removed ugly/unclear code.
- Eror formatters may now format the output differently according to the kind of input, being the input text or the parsed tokens. Formatters now have access to contexts at the moment of handling an error, which can provide more data and information about the current error.
- Remove dead code.
- Simplified the way of getting the forward value internally.
Version 0.1.0
Features
- Add
TextFormatter#removeFormat
. - Tokenizing process now may push multiple errors (instead of being limited to just one)
- Improved displaying of tokenizer errors.
- Add
Argument.PrefixChar#COMMON_PREFIXES
. This is an array of prefixes that a user will normally be familiar with. - Add parse error for when unmatched extra values are present in an argument name list.
- Updated unmatched token error to be clearer.
- Add an info level error for when a token has a correct argument name, but with an incorrect prefix.
- Made argument name list checking more permissive by being less strict with which prefixes you can use. Now also checks if the prefix used is any in
Argument.PrefixChar#COMMON_PREFIXES
.
Fixes
Argument.Define.prefix
now usesArgument.PrefixChar.defaultPrefix
by default, instead of just '-'.- Terminal sequences being reset on some terminals after a newline is shown.
- Slight optimization in
ErrorsContainerImpl
. - Slight optimization in
ModifyRecord
. - Argument
onCorrect
callbacks not executing when other arguments withallowUnique
are present and used. - Incorrect usage count errors appearing for each usage. Now just appearing once, at final parsing of the argument.
- Possibility to set no names on arguments/commands.
ArgumentType#addError
throwingIllegalStateException
instead ofArgumentTypeException
.UtlReflection#instantiate
not properly forwarding the arguments supplied to the ctor.- Incorrect value numbers errors not highlighting tokens correctly.
- Parse errors added by parsing of argument name lists not properly highlighting tokens.
- Incorrect number of values shown on a specific incorrect value number error case.
- Parsing:
- Token being skipped from input in a case when parsing argument name lists.
- Strings not behaving properly when placed right after another value.
- Input incorrectly tokenized as a name list in some cases.
- Parsing occurring even if tokenizing process failed.
- Error decorations not being properly adapted with text on a lower line width limit.
Version 0.0.3
Features
- New Command Template argument types that can be inferred from the field:
File
, giving aFileArgumentType
.String[]
, giving aMultipleStringsArgumentType
.- Array type for all the non-primitive number types (
Integer
,Double
,Byte
, etc). Uses the newMultipleNumbersArgumentType
.
- Improve registering system for infer types. (Now
ArgumentTypeInfer
)- Now accepts function references instead of class types.
- Refactor
TupleArgumentType
so that now it acts as a mapper of strings (argument values) to what a subtype decides to parse to.- Refactor
MultipleStringsArgumentType
andMultipleNumbersArgumentType
to now inherit this class.
- Refactor
- Improve
FileArgumentType
:- Add
mustExist
option. Whentrue
, requires the specified path to exist. - Now possible to specify if the file should be a directory or a regular file.
- Improved the generated description and representation.
- Add
- Change default option chain for
ArgumentParser#parseFromInto
. - Make errors clearer for Command Templates when attempting to instantiate the class fails.
Fixes
- Small optimizations.
FileArgumentType
not behaving as expected.ArgumentTypeInfer#register
allowing to pass no Classes, essentially doing nothing.ArgumentTypeInfer#register
allowing to overwrite previous definitions.- Default version argument showing "Version: null" if no version was defined. Now shows "unknown".
- Synopsis help layout generator appending an extra space character when printing commands.
- Blank string not being detected as no input (
CLInput
).
Version 0.0.2
Features
- Default error formatter generators are now available in
ErrorFormatter.DefaultGenerators
.- Default generator is now
ErrorFormatter.DefaultGenerators.PRETTY
. - Add another generator,
ErrorFormatter.DefaultGenerators.SIMPLE
.
- Default generator is now
- Add
Command#addHelpArgument
andArgumentParser#addVersionArgument
, which add the respective arguments to the command. - Add another name ("h") to the default help argument.
- Add
printHelpIfNoInput()
,exitIfNoInput()
toAfterParseOptions
.
Refactors
DisplayTokenOptions
record now uses aRange
instance instead of anstart
andoffset
value.- Rename
obligatory
torequired
.
Fixes
LayoutItem
no longer display it's title when no contents were generated in it.- Command descriptions are now being properly set from Command Templates.