Skip to content

Releases: darvil82/lanat

Version 1.2.0

26 May 17:22
fd2b6b4
Compare
Choose a tag to compare

Features

  • Allow specifying regular types in Argument.Define. Same behaviour as with regular field types. Will be attempted to be inferred.

Version 1.1.0 - Automatic enum inference

25 May 15:56
8e046d3
Compare
Choose a tag to compare

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

16 May 18:49
Compare
Choose a tag to compare

Documentation now available!

Check out the complete documentation at https://darvil82.github.io/lanat-docs

Features

  • Argument types

    • Add ActionArgumentType. This is the old BooleanArgumentType.
    • BooleanArgumentType can now receive values as well. Those being true, 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() to getArgValuesStream().
    • Add getRequiredUsageCount() to Parseable.
    • Add default implementation to getRequiredUsageCount and getRequiredArgValueCount in Parseable.
    • 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 aforementioned Builder.
    • Add OptListArgumentType. Similar to EnumArgumentType, but accepts a list of all possible strings the user can introduce.
    • Add SingleValueListArgumentType abstract class. EnumArgumentType and OptListArgumentType both inherit this.
    • Add constructor to ArgumentType to pass a Parseable to check restrictions on.
    • Add unregisterSubType() to ArgumentType.
    • Add unregister to ArgumentTypeInfer.
    • Add ArgumentTypeError.
    • Argument types now throw ArgumentTypeError instead of CustomErrorImpl.
  • 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() or into(). 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.
  • Arguments

    • Add visible property. This allows to hide this argument from the help message. Use the setVisible method. This property has been added to ArgumentBuilder and the Argument.Define annotation as well.
    • Remove Argument.createOfBoolType() in favor of new Argument.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(). Returns true 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.
  • Commands

    • Add int parameter to addHelpArgument() and addVersionArgument() to specify the exit code upon quitting.
    • Add onUsed callback. Can be set with setOnUsedCallback(). This callback is functionally equivalent to CommandTemplate#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 the Argument.Define annotation. Multiple argument fields defined with the same group value will be added to a group with that name.
      • Add argWithType helper method to CommandBuildHelper to remove the need to specify type parameters while setting the type.
      • Add CommandTemplate.Default.WithVerbose, which includes a verbose 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 the ParseResult instance as a parameter.
  • Misc

    • Now supports the NO-COLOR environment variable.
    • com.darvil:utils and com.darvil:terminal-text-formatter are now both API dependencies, thus the user will no longer have to manually install them.
    • Add CLInput#fromFile and CLInput#fromStandardInput.
    • Add ArgumentParser#parseFromInto overload that takes String[] 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 implements Builder.
    • ArgumentAdder#addArgument now accepts a generic Builder instance too.
    • Improve toString representation of arguments and commands and groups.
    • Add setNames method to MultipleNamesAndDescription. Implementors now only implement this method. addNames has a default implementation now.
    • Add unregister method to Tag.
    • 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 the color_name|#rrggbb|r,g,b syntax.
    • Add DefaultValueTag for arguments.
    • Errors may now choose to remove other errors by overriding the shouldRemoveOther() method in Error.
      • A RequiredArgumentNotUsedError will no longer appear if an IncorrectValueNumberError is present for the same argument.
      • An UnmatchedTokenError will no longer appear if a SimilarArgumentError is present for the same token index.
    • Add representationColor to ArgumentBuilder.
    • 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 to CustomError (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 throwing IllegalArgumentException instead of MalformedTagException in a case.
  • Fix DescriptionParser not throwing a MalformedTagException 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 to Command. (Can now accept ArgumentParser)
  • Fix program details layout item missing an indentation in the help message.
  • ArgumentTypeInfer allowing to set infer for Optional.
  • 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 to Argument#type. Applies to ArgumentBuilder and Argument.Define as well.
  • Remove Argument.create() overloads involving char.
  • Commands no longer have the ability to define the tuple char to use. This is now globally defined in TupleChar#current.
  • Move CallbacksInvocationOption into Command.
  • Change all \n usages to System#lineSeparator() to improve compatibility.
  • PrefixChar is now an enum. It is no longer allowed to use any character for a prefix. The Argument.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 and MultipleStringsArgumentType. No longer needed with the new TupleArgumentType.
  • 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 and ErrorsContainerImpl to singular Error. (eg, ErrorContain...
Read more

Version 0.3.0

03 Jan 15:32
8b42546
Compare
Choose a tag to compare
Version 0.3.0 Pre-release
Pre-release

Features

  • Rename ParsedArguments to ParseResult.
  • Add more javadocs and improved some other.
  • Add onValuesReceived() to CommandTemplate. This is a method that an inheritor may override.
  • Add getParseResult() to CommandTemplate.
  • Add wasUsed(), getCommand() to CommandTemplate and ParseResult.
  • ParseResult#getSubResult() now returns a non-nullable value. (Now throws if no command was found)
  • Add getUsedResults() to ParseResultRoot.

Fixes

  • Tiny fix on the javadoc of ArgumentGroup.
  • Some other javadoc fixes.

Version 0.2.1

26 Dec 16:53
Compare
Choose a tag to compare
Version 0.2.1 Pre-release
Pre-release
  • "Exclusive" groups are now named "Restricted".
  • Fix restricted groups incorrectly throwing errors for usage violations that do not occur.

Version 0.2.0

14 Dec 00:54
00dce43
Compare
Choose a tag to compare
Version 0.2.0 Pre-release
Pre-release

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 to ParentElementGetter.
  • Default help and version 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 and getCommand 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 ArgumentTypes.
  • Separated unrelated code into separate libraries (#14):
  • Refactors:
    • Tokenizer, Parser and ErrorHandler (now called ErrorsCollector) (#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

06 Nov 01:00
2413530
Compare
Choose a tag to compare
Version 0.1.0 Pre-release
Pre-release

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 uses Argument.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 with allowUnique 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 throwing IllegalStateException instead of ArgumentTypeException.
  • 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

23 Oct 18:53
d99a902
Compare
Choose a tag to compare
Version 0.0.3 Pre-release
Pre-release

Features

  • New Command Template argument types that can be inferred from the field:
    • File, giving a FileArgumentType.
    • String[], giving a MultipleStringsArgumentType.
    • Array type for all the non-primitive number types (Integer, Double, Byte, etc). Uses the new MultipleNumbersArgumentType.
  • 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 and MultipleNumbersArgumentType to now inherit this class.
  • Improve FileArgumentType:
    • Add mustExist option. When true, 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.
  • 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

21 Sep 14:58
Compare
Choose a tag to compare
Version 0.0.2 Pre-release
Pre-release

Features

  • Default error formatter generators are now available in ErrorFormatter.DefaultGenerators.
    • Default generator is now ErrorFormatter.DefaultGenerators.PRETTY.
    • Add another generator, ErrorFormatter.DefaultGenerators.SIMPLE.
  • Add Command#addHelpArgument and ArgumentParser#addVersionArgument, which add the respective arguments to the command.
  • Add another name ("h") to the default help argument.
  • Add printHelpIfNoInput(), exitIfNoInput() to AfterParseOptions.

Refactors

  • DisplayTokenOptions record now uses a Range instance instead of an start and offset value.
  • Rename obligatory to required.

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.

Version 0.0.1

14 Sep 11:59
Compare
Choose a tag to compare
Version 0.0.1 Pre-release
Pre-release

New features

  • Formatting for object descriptions. by @darvil82 in #3
  • Options after parse by @darvil82 in #5
    • Command Templates using reflection.
  • Many more things I likely forgot.

Bugs fixed

  • A ton.