java.lang.Object
org.refcodes.archetype.CliHelper
org.refcodes.archetype.AppHelper
- All Implemented Interfaces:
org.refcodes.cli.Optionable
,org.refcodes.mixin.VerboseAccessor
The
AppHelper
is a stripped down CliHelper
intended to be
used by GUI applications which must(!) avoid (to link to)
java.awt
which might not be available on a target platform such
as Android. Background: For mere nerd purposes, the CliHelper
comes
with a full blown ASCII-Art banner which uses an AWT graphics context to
convert text fonts or graphics to ASCII-Art. The AWT graphics context is not
available on Android and causes applications built with the GraalVM and
Gluon's substrate to crash as of an unavailable "fontmanager symbol".-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.VerboseAccessor
org.refcodes.mixin.VerboseAccessor.VerboseMutator, org.refcodes.mixin.VerboseAccessor.VerboseProperty
-
Field Summary
Fields inherited from class org.refcodes.archetype.CliHelper
_properties, DEFAULT_CONFIG_LOCATOR, DEFAULT_PASSWORD_PROMPT, DEFAULT_SYNTAX_NOTATION
-
Constructor Summary
ConstructorDescriptionAppHelper
(String[] aArgs, char aShortOptionPrefix, String aLongOptionPrefix, org.refcodes.cli.Condition aArgsSyntax, org.refcodes.cli.SyntaxNotation aSyntaxNotation, Collection<org.refcodes.cli.Example> aExamples, String aDefaultConfig, org.refcodes.runtime.ConfigLocator aConfigLocator, Class<?> aResourceLocator, String aName, String aTitle, String aPasswordPrompt, String aDescription, String aCopyrightNote, String aLicenseNote, org.refcodes.textual.Font aBannerFont, char[] aBannerFontPalette, boolean aVerboseFallback, org.refcodes.logger.RuntimeLogger aLogger, Consumer<Integer> aShutdownHook) -
Method Summary
Modifier and TypeMethodDescriptionstatic AppHelper.Builder
builder()
Creates builder to buildAppHelper
.protected void
Prints the application's banner to the console.protected void
Prints the application's help to the console.Methods inherited from class org.refcodes.archetype.CliHelper
createResourceFile, createResourceFile, exit, exit, exitOnException, getRuntimeProperties, isVerbose, printException, printSysInfo, readPassword, readPassword, toOptions
-
Constructor Details
-
AppHelper
public AppHelper(String[] aArgs, char aShortOptionPrefix, String aLongOptionPrefix, org.refcodes.cli.Condition aArgsSyntax, org.refcodes.cli.SyntaxNotation aSyntaxNotation, Collection<org.refcodes.cli.Example> aExamples, String aDefaultConfig, org.refcodes.runtime.ConfigLocator aConfigLocator, Class<?> aResourceLocator, String aName, String aTitle, String aPasswordPrompt, String aDescription, String aCopyrightNote, String aLicenseNote, org.refcodes.textual.Font aBannerFont, char[] aBannerFontPalette, boolean aVerboseFallback, org.refcodes.logger.RuntimeLogger aLogger, Consumer<Integer> aShutdownHook) Creates a newAppHelper
using the provided application'sRuntimeLogger
so that logs produced by theAppHelper
are logged according to the application'sRuntimeLogger
configuration (depending on the RuntimeLogger.ini file).- Parameters:
aArgs
- The command line arguments.aShortOptionPrefix
- The short options' prefix to be set.aLongOptionPrefix
- The long options' prefix to be set.aArgsSyntax
- The root elelemt of your command line syntax.aSyntaxNotation
- TheSyntaxNotation
to use.aExamples
- TheExample
examples to use when printing out the help.aDefaultConfig
- The name to your default config file.aConfigLocator
- TheConfigLocator
to use when locating the configuration file (defaults toConfigLocator.DEFAULT
.aResourceLocator
- The application'sClass
which to use when loading resources (of the according module) by invokingClass.getResourceAsStream(String)
.aName
- The name of your application.aTitle
- The title of the application.aPasswordPrompt
- The prompt to use when requesting a password.aDescription
- The description to use when printing out the help.aCopyrightNote
- The copyright being applied.aLicenseNote
- The license for the application.aBannerFont
- The font for the banner to use.aBannerFontPalette
- The ASCII color palette for the banner to use.aVerboseFallback
- The fallback verbose mode if the verbose mode cannot be determined otherwise.aLogger
- The application's logger.aShutdownHook
- When provided, then this hook is called instead ofSystem.exit(int)
(it is up to the shutdown hook to terminate the application in the end).
-
-
Method Details
-
builder
Creates builder to buildAppHelper
.- Returns:
- created builder
-
printBanner
protected void printBanner()Prints the application's banner to the console.- Overrides:
printBanner
in classCliHelper
-
printHelp
protected void printHelp()Prints the application's help to the console.
-