├── .drone.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.adoc ├── crest-maven-plugin ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── tomitribe │ │ └── crest │ │ └── maven │ │ └── CrestCommandLoaderDescriptorGeneratorMojo.java │ └── test │ └── java │ └── org │ └── tomitribe │ └── crest │ └── maven │ └── CrestCommandLoaderDescriptorGeneratorMojoTest.java ├── pom.xml ├── tomitribe-crest-api ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── tomitribe │ └── crest │ └── api │ ├── Command.java │ ├── CrestAnnotation.java │ ├── Default.java │ ├── Defaults.java │ ├── Editor.java │ ├── Err.java │ ├── Exit.java │ ├── In.java │ ├── Loader.java │ ├── NotAService.java │ ├── Option.java │ ├── Options.java │ ├── Out.java │ ├── PrintOutput.java │ ├── Required.java │ ├── StreamingOutput.java │ ├── interceptor │ ├── CrestContext.java │ ├── CrestInterceptor.java │ └── ParameterMetadata.java │ ├── table │ ├── Border.java │ ├── Table.java │ └── TableOptions.java │ └── validation │ └── Validation.java ├── tomitribe-crest-archetype ├── pom.xml └── src │ └── main │ └── resources │ ├── META-INF │ ├── LICENSE │ ├── NOTICE │ ├── archetype-post-generate.groovy │ └── maven │ │ └── archetype-metadata.xml │ └── archetype-resources │ ├── README.adoc │ ├── pom.xml │ └── src │ ├── main │ └── java │ │ ├── App.java │ │ ├── FileEditor.java │ │ └── IsFile.java │ └── test │ └── java │ └── AppTest.java ├── tomitribe-crest-arthur-extension ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── tomitribe │ │ │ └── crest │ │ │ └── arthur │ │ │ ├── CrestExtension.java │ │ │ └── feature │ │ │ └── CrestFeature.java │ └── resources │ │ └── META-INF │ │ └── services │ │ ├── org.apache.geronimo.arthur.spi.ArthurExtension │ │ └── org.graalvm.compiler.options.OptionDescriptors │ └── test │ └── java │ └── org │ └── tomitribe │ └── crest │ └── arthur │ └── CrestExtensionTest.java ├── tomitribe-crest-cli ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── tomitribe │ │ └── crest │ │ └── cli │ │ ├── api │ │ ├── CliEnvironment.java │ │ ├── CrestCli.java │ │ ├── InputReader.java │ │ ├── format │ │ │ └── Table.java │ │ └── interceptor │ │ │ ├── base │ │ │ └── ParameterVisitor.java │ │ │ └── interactive │ │ │ ├── Interactivable.java │ │ │ └── InteractiveMissingParameters.java │ │ └── impl │ │ ├── CliEnv.java │ │ ├── CommandParser.java │ │ └── command │ │ ├── JSonP.java │ │ └── Streams.java │ └── test │ └── java │ └── org │ └── tomitribe │ └── crest │ └── cli │ ├── api │ ├── CrestCliTest.java │ └── format │ │ └── TableTest.java │ └── impl │ └── CommandParserTest.java ├── tomitribe-crest-generator ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── tomitribe │ │ │ └── crest │ │ │ └── generator │ │ │ └── CrestBindingGeneratorProcessor.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── javax.annotation.processing.Processor │ └── test │ └── java │ └── org │ └── tomitribe │ └── crest │ └── generator │ └── CrestBindingGeneratorProcessorTest.java ├── tomitribe-crest-test ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── tomitribe │ │ └── crest │ │ └── test │ │ ├── Jar.java │ │ ├── Jars.java │ │ └── Java.java │ └── test │ └── java │ └── org │ └── tomitribe │ └── crest │ └── test │ ├── Hello.java │ └── JarTest.java ├── tomitribe-crest-xbean ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── tomitribe │ │ │ └── crest │ │ │ └── xbean │ │ │ ├── ClasspathScanner.java │ │ │ ├── UberJarScanner.java │ │ │ └── XbeanScanningLoader.java │ └── resources │ │ └── META-INF │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── services │ │ └── org.tomitribe.crest.cmds.processors.Commands$Loader │ └── test │ └── java │ └── org │ └── tomitribe │ └── crest │ └── xbean │ └── XbeanScanningLoaderTest.java ├── tomitribe-crest ├── pom.xml └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── tomitribe │ │ │ └── crest │ │ │ ├── BashCompletion.java │ │ │ ├── EditorLoader.java │ │ │ ├── Exec.java │ │ │ ├── Main.java │ │ │ ├── Manifest.java │ │ │ ├── cmds │ │ │ ├── Cmd.java │ │ │ ├── CmdGroup.java │ │ │ ├── CmdMethod.java │ │ │ ├── CommandFailedException.java │ │ │ ├── Completer.java │ │ │ ├── HelpPrintedException.java │ │ │ ├── MissingArgumentException.java │ │ │ ├── OverloadedCmdMethod.java │ │ │ ├── processors │ │ │ │ ├── Commands.java │ │ │ │ ├── Help.java │ │ │ │ ├── Item.java │ │ │ │ ├── OptionParam.java │ │ │ │ ├── Param.java │ │ │ │ └── types │ │ │ │ │ └── PrimitiveTypes.java │ │ │ ├── targets │ │ │ │ ├── SimpleBean.java │ │ │ │ ├── Substitution.java │ │ │ │ └── Target.java │ │ │ └── utils │ │ │ │ └── CommandLine.java │ │ │ ├── contexts │ │ │ ├── DefaultsContext.java │ │ │ ├── EnvDefaultsContext.java │ │ │ └── SystemPropertiesDefaultsContext.java │ │ │ ├── environments │ │ │ ├── Environment.java │ │ │ └── SystemEnvironment.java │ │ │ ├── help │ │ │ ├── Bullet.java │ │ │ ├── CommandJavadoc.java │ │ │ ├── Document.java │ │ │ ├── DocumentFormatter.java │ │ │ ├── DocumentParser.java │ │ │ ├── Element.java │ │ │ ├── Heading.java │ │ │ ├── HelpProcessor.java │ │ │ ├── Highlight.java │ │ │ ├── HtmlDocumentParser.java │ │ │ ├── IllegalElementException.java │ │ │ ├── InvalidJavadocFileException.java │ │ │ ├── Justify.java │ │ │ ├── Option.java │ │ │ ├── Paragraph.java │ │ │ ├── Preformatted.java │ │ │ └── Wrap.java │ │ │ ├── interceptor │ │ │ ├── InterceptorAnnotationNotFoundException.java │ │ │ ├── UnresolvedInterceptorAnnotationException.java │ │ │ ├── internal │ │ │ │ ├── InternalInterceptor.java │ │ │ │ └── InternalInterceptorInvocationContext.java │ │ │ └── security │ │ │ │ ├── RoleProvider.java │ │ │ │ └── SecurityInterceptor.java │ │ │ ├── javadoc │ │ │ ├── Javadoc.java │ │ │ └── JavadocParser.java │ │ │ ├── lang │ │ │ └── Substitutor.java │ │ │ ├── table │ │ │ ├── Border.java │ │ │ ├── Data.java │ │ │ ├── Formatting.java │ │ │ ├── Line.java │ │ │ ├── Lines.java │ │ │ ├── Options.java │ │ │ ├── Parts.java │ │ │ ├── Resize.java │ │ │ ├── Table.java │ │ │ ├── TableInterceptor.java │ │ │ ├── TableOutput.java │ │ │ ├── Tables.java │ │ │ └── Width.java │ │ │ ├── term │ │ │ └── Screen.java │ │ │ └── val │ │ │ ├── BVal05.java │ │ │ ├── BeanValidation.java │ │ │ ├── BeanValidation11.java │ │ │ ├── BeanValidationImpl.java │ │ │ ├── BeanValidationMessages.java │ │ │ ├── BuiltInValidation.java │ │ │ ├── ConstraintAdapter.java │ │ │ ├── Directory.java │ │ │ ├── Executable.java │ │ │ ├── Exists.java │ │ │ ├── Readable.java │ │ │ └── Writable.java │ └── resources │ │ ├── META-INF │ │ ├── LICENSE │ │ └── NOTICE │ │ ├── ValidationMessages.properties │ │ ├── ValidationMessages_en.properties │ │ └── ValidationMessages_pt_BR.properties │ └── test │ ├── java │ └── org │ │ └── tomitribe │ │ └── crest │ │ ├── AdvancedArrayArgTest.java │ │ ├── Archives.java │ │ ├── ArgArraysTest.java │ │ ├── ArgListsTest.java │ │ ├── BashCompletionTest.java │ │ ├── BeanValidationTest.java │ │ ├── BenInjectionPrefixTest.java │ │ ├── BooleanOptionsTest.java │ │ ├── Cli.java │ │ ├── CmdMethodTest.java │ │ ├── CommandNameAndVersionTest.java │ │ ├── CompleterTest.java │ │ ├── Crest.java │ │ ├── DefaultInterpolationTest.java │ │ ├── DefaultListOptionSplittingTest.java │ │ ├── DefaultOptionListsAndOptionsTest.java │ │ ├── DefaultOptionListsTest.java │ │ ├── DefaultOptionsAndSuppliedArgsTest.java │ │ ├── DefaultSubstitutionTest.java │ │ ├── EditorInLoaderTest.java │ │ ├── EnumOptionListTest.java │ │ ├── ExceptionHandlingTest.java │ │ ├── ExplicitPrimitiveOptionDefaultsTest.java │ │ ├── Foo.java │ │ ├── HelpTest.java │ │ ├── HelpWithInnerOptionsTest.java │ │ ├── ImplicitPrimitiveOptionDefaultsTest.java │ │ ├── InterceptorTest.java │ │ ├── Java.java │ │ ├── MainBuilderTest.java │ │ ├── MainTest.java │ │ ├── ManifestTest.java │ │ ├── ManyOptionTest.java │ │ ├── MissingArgumentTest.java │ │ ├── NullableOptionsTest.java │ │ ├── OptionArraysTest.java │ │ ├── OptionListsTest.java │ │ ├── OptionsObjectAdvancedArrayArgTest.java │ │ ├── OptionsObjectTest.java │ │ ├── OptionsObjectValidationTest.java │ │ ├── OverloadedCmdHelpTest.java │ │ ├── OverloadedCmdMethodTest.java │ │ ├── PluggableDefaultParsingTest.java │ │ ├── PrimitiveTypesTest.java │ │ ├── ServiceInjectionTest.java │ │ ├── SomeOptionsAndSuppliedArgsTest.java │ │ ├── StreamInjectionTest.java │ │ ├── SubCommandsTest.java │ │ ├── SubstitutionTest.java │ │ ├── SupportedCollectionTypesTest.java │ │ ├── SystemPropertiesTest.java │ │ ├── ValidationTest.java │ │ ├── VarargStreamTest.java │ │ ├── cmds │ │ └── utils │ │ │ └── CommandLineTest.java │ │ ├── help │ │ ├── AuthorTest.java │ │ ├── DefaultsShownTest.java │ │ ├── DocumentFormatterTest.java │ │ ├── DocumentParserTest.java │ │ ├── GenericsInMethodSignatureTest.java │ │ ├── HighlightTest.java │ │ ├── JavadocHelpComplexTest.java │ │ ├── JustifyTest.java │ │ ├── ManualTest.java │ │ ├── ParamWithPreformattedTextTest.java │ │ ├── RsyncManPage.java │ │ ├── SeeAlsoTest.java │ │ ├── SubcommandTest.java │ │ ├── TestEnvironment.java │ │ └── WrapTest.java │ │ ├── interceptor │ │ ├── CustomInterceptorAnnotationTest.java │ │ └── security │ │ │ └── SecurityInterceptorTest.java │ │ ├── javadoc │ │ └── JavadocParserTest.java │ │ ├── returns │ │ └── ReturnStringArrayArrayTest.java │ │ ├── table │ │ ├── DataTest.java │ │ ├── FormattingItemTest.java │ │ ├── FormattingTest.java │ │ ├── PartsTest.java │ │ ├── TableBorderNoHeaderTest.java │ │ ├── TableBorderTest.java │ │ ├── TableFieldsTest.java │ │ ├── TableHeaderTest.java │ │ ├── TableOptionsTest.java │ │ ├── TableSortTest.java │ │ ├── TableTest.java │ │ ├── TableWrappingTest.java │ │ └── WidthTest.java │ │ └── util │ │ ├── ConverterTest.java │ │ ├── DurationTest.java │ │ ├── SizeTest.java │ │ ├── SizeUnitTest.java │ │ └── TimeUtilsTest.java │ └── resources │ ├── TableBorderNoHeaderTest │ ├── asciiCompact.txt │ ├── asciiDots.txt │ ├── asciiSeparated.txt │ ├── githubMarkdown.txt │ ├── mysqlStyle.txt │ ├── reStructuredTextGrid.txt │ ├── reStructuredTextSimple.txt │ ├── redditMarkdown.txt │ ├── unicodeDouble.txt │ ├── unicodeSingle.txt │ ├── unicodeSingleSeparated.txt │ ├── whitespaceCompact.txt │ └── whitespaceSeparated.txt │ ├── TableBorderTest │ ├── asciiCompact.txt │ ├── asciiDots.txt │ ├── asciiSeparated.txt │ ├── githubMarkdown.txt │ ├── mysqlStyle.txt │ ├── reStructuredTextGrid.txt │ ├── reStructuredTextSimple.txt │ ├── redditMarkdown.txt │ ├── unicodeDouble.txt │ ├── unicodeSingle.txt │ ├── unicodeSingleSeparated.txt │ ├── whitespaceCompact.txt │ └── whitespaceSeparated.txt │ ├── completion │ ├── booleanoption.sh │ ├── defaults.sh │ ├── enums.sh │ ├── foo.sh │ ├── groups.sh │ └── overloaded.sh │ ├── help │ ├── org.tomitribe.crest.AdvancedArrayArgTest$OneExtra_copy.txt │ ├── org.tomitribe.crest.AdvancedArrayArgTest$RequiredList_copy.txt │ ├── org.tomitribe.crest.AdvancedArrayArgTest$TwoExtra_copy.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doByte.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doChar.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doInt.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doLong.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doShort.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doString.txt │ ├── org.tomitribe.crest.ArgArraysTest$Commands_doURI.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doCharacter.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doString.txt │ ├── org.tomitribe.crest.ArgListsTest$Commands_doURI.txt │ ├── org.tomitribe.crest.BeanValidationTest$Duplicates_check.txt │ ├── org.tomitribe.crest.BeanValidationTest$Duplicates_empty.txt │ ├── org.tomitribe.crest.BooleanOptionsTest$Commands_object.txt │ ├── org.tomitribe.crest.BooleanOptionsTest$Commands_object2.txt │ ├── org.tomitribe.crest.BooleanOptionsTest$Commands_object3.txt │ ├── org.tomitribe.crest.BooleanOptionsTest$Commands_primitive.txt │ ├── org.tomitribe.crest.BooleanOptionsTest$Commands_primitive2.txt │ ├── org.tomitribe.crest.BooleanOptionsTest$Commands_primitive3.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_booleanOption.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_cat.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_ls.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_prefixed.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_required.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_set.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_tail.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_tar.txt │ ├── org.tomitribe.crest.CmdMethodTest$Commands_touch.txt │ ├── org.tomitribe.crest.CompleterTest$Copy_copy.txt │ ├── org.tomitribe.crest.CompleterTest$Foo_blue.txt │ ├── org.tomitribe.crest.CompleterTest$Foo_green.txt │ ├── org.tomitribe.crest.CompleterTest$Foo_red.txt │ ├── org.tomitribe.crest.CompleterTest$Git_git.txt │ ├── org.tomitribe.crest.CompleterTest$Git_git_push.txt │ ├── org.tomitribe.crest.CompleterTest$Svn_svn.txt │ ├── org.tomitribe.crest.CompleterTest$Svn_svn_checkout.txt │ ├── org.tomitribe.crest.CompleterTest$Svn_svn_commit.txt │ ├── org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onComma.txt │ ├── org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onTab.txt │ ├── org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onUnicode.txt │ ├── org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onlyBeforeSubstition.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doCharacter.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doString.txt │ ├── org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doURI.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doCharacter.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doString.txt │ ├── org.tomitribe.crest.DefaultOptionListsTest$Commands_doURI.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doChar.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doMixed.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doString.txt │ ├── org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doURI.txt │ ├── org.tomitribe.crest.DefaultSubstitutionTest$Commands_doAllExplicit.txt │ ├── org.tomitribe.crest.DefaultSubstitutionTest$Commands_doRelyOnDefaults.txt │ ├── org.tomitribe.crest.EnumOptionListTest$Commands_array.txt │ ├── org.tomitribe.crest.EnumOptionListTest$Commands_list.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doAll.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doChar.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.HelpTest$DefaultsAndEnums_test.txt │ ├── org.tomitribe.crest.HelpTest$Git_git.txt │ ├── org.tomitribe.crest.HelpTest$Git_git_pull.txt │ ├── org.tomitribe.crest.HelpTest$Git_git_push.txt │ ├── org.tomitribe.crest.HelpTest$OptionLists_test.txt │ ├── org.tomitribe.crest.HelpTest$Rsync_rsync.txt │ ├── org.tomitribe.crest.HelpWithInnerOptionsTest$DefaultsAndEnums_test.txt │ ├── org.tomitribe.crest.HelpWithInnerOptionsTest$OptionLists_test.txt │ ├── org.tomitribe.crest.HelpWithInnerOptionsTest$Rsync_rsync.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doAll.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doChar.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.MainTest$Foo_blue.txt │ ├── org.tomitribe.crest.MainTest$Foo_green.txt │ ├── org.tomitribe.crest.MainTest$Foo_red.txt │ ├── org.tomitribe.crest.ManyOptionTest$Commands_doString.txt │ ├── org.tomitribe.crest.ManyOptionTest$Commands_rsync.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doByte.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doChar.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doInt.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doLong.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doShort.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doString.txt │ ├── org.tomitribe.crest.OptionArraysTest$Commands_doURI.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doCharacter.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doString.txt │ ├── org.tomitribe.crest.OptionListsTest$Commands_doURI.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_args.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex2.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex3.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex4.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex5.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_mixed.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_options.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_optionsAndArgs.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_simple.txt │ ├── org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_twoBeans.txt │ ├── org.tomitribe.crest.OptionsObjectTest$Commands_args.txt │ ├── org.tomitribe.crest.OptionsObjectTest$Commands_mixed.txt │ ├── org.tomitribe.crest.OptionsObjectTest$Commands_options.txt │ ├── org.tomitribe.crest.OptionsObjectTest$Commands_optionsAndArgs.txt │ ├── org.tomitribe.crest.OptionsObjectTest$Commands_twoBeans.txt │ ├── org.tomitribe.crest.OptionsObjectValidationTest$Commands_validation.txt │ ├── org.tomitribe.crest.OverloadedCmdMethodTest$TestCommands_help.txt │ ├── org.tomitribe.crest.PluggableDefaultParsingTest$Orange_defaults.txt │ ├── org.tomitribe.crest.PluggableDefaultParsingTest$Orange_property.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doBoolean.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doByte.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doChar.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doDouble.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doFloat.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doInt.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doLong.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doMixed.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doShort.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doString.txt │ ├── org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doURI.txt │ ├── org.tomitribe.crest.SubCommandsTest$Git_git.txt │ ├── org.tomitribe.crest.SubCommandsTest$Git_git_pull.txt │ ├── org.tomitribe.crest.SubCommandsTest$Git_git_push.txt │ ├── org.tomitribe.crest.SystemPropertiesTest$Orange_defaults.txt │ └── org.tomitribe.crest.SystemPropertiesTest$Orange_property.txt │ ├── man │ ├── expected-106.txt │ ├── expected-178.txt │ ├── expected-86.txt │ └── input-markdown.txt │ └── org │ └── tomitribe │ └── crest │ ├── OptionDescriptions.properties │ └── OptionDescriptions_en.properties └── toolz ├── pom.xml └── src ├── main ├── java │ └── org │ │ └── example │ │ └── toolz │ │ ├── AnyName.java │ │ ├── App.java │ │ └── IsFile.java └── resources │ ├── META-INF │ ├── LICENSE │ └── NOTICE │ └── org │ └── example │ └── toolz │ └── OptionDescriptions.properties └── test └── java └── org └── example └── toolz └── AppTest.java /.drone.yml: -------------------------------------------------------------------------------- 1 | build: 2 | image: teaci/cygwin32 3 | shell: cygwin32 4 | pull: true 5 | commands: 6 | - cmd /c c:/cygwin-installer.exe --site http://mirrors.tea-ci.org/cygwin --local-package-dir Z:/tmp/cygwin -W -P cabextract,unzip -q 7 | - echo '' > run.bat 8 | - wget http://repo.apache.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 9 | - unzip apache-maven-3.3.9-bin.zip 10 | - wget '--header' 'Cookie:oraclelicense=accept-securebackup-cookie' '--no-cookies' '--no-check-certificate' "http://download.oracle.com/otn-pub/java/jdk/8u91-b15/jdk-8u91-windows-i586.exe" 11 | - chmod ogu+rwx jdk-8u91-windows-i586.exe 12 | - cabextract jdk-8u91-windows-i586.exe || echo "ignoring errors" 13 | - mkdir jdk && mv tools.zip jdk && cd jdk && unzip tools.zip && for i in jre/lib/charsets jre/lib/deploy jre/lib/ext/localedata jre/lib/javaws jre/lib/jsse jre/lib/plugin jre/lib/rt lib/tools; do ./bin/unpack200 -r -v -l "" $i.pack $i.jar; done && cd - 14 | - echo set JAVA_HOME=$(cygpath.exe --windows $PWD/jdk) > run.bat 15 | - echo set M2_HOME=$(cygpath.exe --windows $PWD/apache-maven-3.3.9) >> run.bat 16 | - echo 'set Path=%JAVA_HOME%\bin;%M2_HOME%\bin;%Path%' >> run.bat 17 | - echo '%JAVA_HOME%\bin\java -cp %M2_HOME%\boot\plexus-classworlds-2.5.2.jar -Dclassworlds.conf=%M2_HOME%/bin/m2.conf -Dmaven.home=%M2_HOME% -Dmaven.multiModuleProjectDirectory=. org.codehaus.plexus.classworlds.launcher.Launcher clean install' >> run.bat 18 | - cmd /c run.bat 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Java # 2 | *.class 3 | 4 | 5 | # Package Files # 6 | *.jar 7 | *.war 8 | *.ear 9 | 10 | # IDEA # 11 | *.iml 12 | .idea 13 | *~ 14 | 15 | # eclipse specific git ignore 16 | .project 17 | .metadata 18 | .classpath 19 | .settings/ 20 | 21 | 22 | # Maven files # 23 | target/ 24 | pom.xml.tag 25 | pom.xml.releaseBackup 26 | pom.xml.next 27 | release.properties 28 | dependency-reduced-pom.xml 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | before_script: 3 | - export MAVEN_SKIP_RC=true 4 | jdk: 5 | - openjdk7 6 | - oraclejdk8 7 | -------------------------------------------------------------------------------- /tomitribe-crest-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 4.0.0 24 | 25 | 26 | org.tomitribe 27 | tomitribe-crest-parent 28 | 0.36-SNAPSHOT 29 | 30 | 31 | tomitribe-crest-api 32 | jar 33 | Tomitribe :: Crest :: API 34 | 35 | 36 | ${project.groupId}.crest.api 37 | 38 | 39 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Command.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @version $Revision$ $Date$ 26 | */ 27 | @Retention(value = RetentionPolicy.RUNTIME) 28 | @Target({ElementType.METHOD, ElementType.TYPE}) 29 | public @interface Command { 30 | String value() default ""; 31 | 32 | String usage() default ""; 33 | 34 | Class[] interceptedBy() default {}; 35 | } 36 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/CrestAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.Retention; 20 | 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | @Retention(RUNTIME) 24 | public @interface CrestAnnotation { 25 | boolean skipUsage() default false; 26 | } 27 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Default.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @version $Revision$ $Date$ 26 | */ 27 | @Retention(value = RetentionPolicy.RUNTIME) 28 | @Target(value = ElementType.PARAMETER) 29 | public @interface Default { 30 | String value(); 31 | } 32 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Defaults.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Repeatable; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * override defaults for a parameter bean. 27 | */ 28 | @Retention(value = RetentionPolicy.RUNTIME) 29 | @Target(value = ElementType.PARAMETER) 30 | public @interface Defaults { 31 | DefaultMapping[] value(); 32 | 33 | @Repeatable(Defaults.class) 34 | @Retention(value = RetentionPolicy.RUNTIME) 35 | @Target(value = ElementType.PARAMETER) 36 | @interface DefaultMapping { 37 | /** 38 | * @return short name (without prefix) of the parameter. 39 | */ 40 | String name(); 41 | 42 | /** 43 | * @return parameter default value. 44 | */ 45 | String value(); 46 | 47 | /** 48 | * @return overriden description for the parameter. 49 | */ 50 | String description() default ""; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Editor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.tomitribe.crest.api; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Retention(value = RetentionPolicy.RUNTIME) 26 | @Target({ ElementType.TYPE}) 27 | public @interface Editor { 28 | Class value(); 29 | } 30 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Err.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | @CrestAnnotation(skipUsage = true) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target(ElementType.PARAMETER) 27 | public @interface Err { 28 | } 29 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Exit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * Usable on an exception type to indicate the 26 | * status code that should be returned 27 | * 28 | * The message of the exception will be printed 29 | * 30 | * @version $Revision$ $Date$ 31 | */ 32 | @Retention(value = RetentionPolicy.RUNTIME) 33 | @Target(ElementType.TYPE) 34 | public @interface Exit { 35 | int value(); 36 | 37 | boolean help() default false; 38 | } 39 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/In.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | @CrestAnnotation(skipUsage = true) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target(ElementType.PARAMETER) 27 | public @interface In { 28 | } 29 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Loader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.util.ArrayList; 20 | import java.util.Arrays; 21 | import java.util.Iterator; 22 | import java.util.List; 23 | 24 | /** 25 | * Interface whose only purpose is to be used in conjunction 26 | * with the java.util.ServiceLoader API as one potential 27 | * way to load the list of classes that have commands. 28 | * 29 | * This interface intentionally has zero methods and never will 30 | * so that the simplest implementation is a plain java.util.ArrayList 31 | * (or pick your favorite collection) 32 | * 33 | * This interface is intentionally not used in any method or constructor of crest. 34 | */ 35 | public interface Loader extends Iterable> { 36 | 37 | static Iterator> of(final Class commandClass, final Class... commandClasses) { 38 | final List> list = new ArrayList<>(); 39 | list.add(commandClass); 40 | list.addAll(Arrays.asList(commandClasses)); 41 | return list.iterator(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/NotAService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.Target; 21 | 22 | import static java.lang.annotation.ElementType.PARAMETER; 23 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 24 | 25 | /** 26 | * intended to skip service injection tentative for this parameter if other tries failed. 27 | */ 28 | @Retention(RUNTIME) 29 | @Target(PARAMETER) 30 | public @interface NotAService { 31 | } 32 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @version $Revision$ $Date$ 26 | */ 27 | @Retention(value = RetentionPolicy.RUNTIME) 28 | @Target(value = ElementType.PARAMETER) 29 | public @interface Option { 30 | String[] value(); 31 | String description() default ""; 32 | } 33 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Options.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @version $Revision$ $Date$ 26 | */ 27 | @Retention(value = RetentionPolicy.RUNTIME) 28 | @Target(value = ElementType.TYPE) 29 | public @interface Options { 30 | /** 31 | * Allow to get null instead of a wrapper instance initialized from defaults. 32 | * 33 | * @return true if the parameter can be null if no value is set from the command line, false otherwise. 34 | */ 35 | boolean nillable() default false; 36 | } 37 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Out.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | @CrestAnnotation(skipUsage = true) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | @Target(ElementType.PARAMETER) 27 | public @interface Out { 28 | } 29 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/PrintOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.io.IOException; 20 | import java.io.PrintStream; 21 | 22 | public interface PrintOutput { 23 | public void write(final PrintStream os) throws IOException; 24 | } 25 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/Required.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @version $Revision$ $Date$ 26 | */ 27 | @Retention(value = RetentionPolicy.RUNTIME) 28 | @Target(value = ElementType.PARAMETER) 29 | public @interface Required { 30 | } 31 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/StreamingOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api; 18 | 19 | import java.io.IOException; 20 | import java.io.OutputStream; 21 | 22 | public interface StreamingOutput { 23 | public void write(OutputStream os) throws IOException; 24 | } 25 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/interceptor/CrestContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api.interceptor; 18 | 19 | import java.lang.reflect.Method; 20 | import java.util.List; 21 | 22 | public interface CrestContext { 23 | /** 24 | * @return continue the execution of the command. 25 | */ 26 | Object proceed(); 27 | 28 | /** 29 | * @return get the command method. 30 | */ 31 | Method getMethod(); 32 | 33 | /** 34 | * @return get the mutable list of command parameters. 35 | */ 36 | List getParameters(); 37 | 38 | /** 39 | * @return the command name. 40 | */ 41 | String getName(); 42 | 43 | /** 44 | * @return the metadata about parameters. 45 | */ 46 | List getParameterMetadata(); 47 | } 48 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/interceptor/CrestInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api.interceptor; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.Target; 21 | 22 | import static java.lang.annotation.ElementType.METHOD; 23 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 24 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 25 | 26 | /** 27 | * A crest interceptor is defined by this annotation at method level. 28 | * The signature needs to be public Object <name>(CrestContext ctx); 29 | */ 30 | @Retention(RUNTIME) 31 | @Target({METHOD, ANNOTATION_TYPE}) 32 | public @interface CrestInterceptor { 33 | /** 34 | * When used on an annotation, allows the interceptor class to be supplied. This 35 | * is an alternative to using @Command(interceptedBy) to supply the interceptor 36 | * class. 37 | */ 38 | Class value() default Object.class; 39 | } 40 | -------------------------------------------------------------------------------- /tomitribe-crest-api/src/main/java/org/tomitribe/crest/api/validation/Validation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.api.validation; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.Target; 21 | 22 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 23 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 24 | 25 | /** 26 | * Mark an annotation as being a command parameter validation. 27 | * It takes the implementation as parameter ({@code value()}). 28 | * {@code Consumer} and {@code BiConsumer} are supported where {@code A} is the annotation and {@code V} the parameter value. 29 | * If the validation fails it must throw a runtime exception and the error message will be captured by crest. 30 | */ 31 | @Target(ANNOTATION_TYPE) 32 | @Retention(RUNTIME) 33 | public @interface Validation { 34 | /** 35 | * @return the validation implementation. 36 | */ 37 | Class value(); 38 | } 39 | -------------------------------------------------------------------------------- /tomitribe-crest-archetype/src/main/resources/META-INF/NOTICE: -------------------------------------------------------------------------------- 1 | Tomitribe :: Crest Archetype 2 | Copyright 2014 Tomitribe Corporation 3 | 4 | This product includes software developed at 5 | Tomitribe Corporation (http://www.tomitribe.com/). 6 | 7 | 8 | -------------------------------------------------------------------------------- /tomitribe-crest-archetype/src/main/resources/archetype-resources/README.adoc: -------------------------------------------------------------------------------- 1 | = $artifactId Crest Project 2 | 3 | This project was created using Crest Archetype. 4 | 5 | == Build 6 | 7 | `mvn package` builds the project and creates an executable uberjar (all in one) which means you can then run your CLI with: 8 | 9 | [source,bash] 10 | ---- 11 | java -jar target/-all.jar 12 | ---- 13 | -------------------------------------------------------------------------------- /tomitribe-crest-archetype/src/main/resources/archetype-resources/src/main/java/FileEditor.java: -------------------------------------------------------------------------------- 1 | package $groupId; 2 | 3 | import org.tomitribe.crest.api.Editor; 4 | import org.tomitribe.util.editor.AbstractConverter; 5 | 6 | import java.io.File; 7 | 8 | @Editor(File.class) 9 | public class FileEditor extends AbstractConverter { 10 | @Override 11 | protected Object toObjectImpl(final String s) { 12 | return new File(s); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tomitribe-crest-archetype/src/main/resources/archetype-resources/src/main/java/IsFile.java: -------------------------------------------------------------------------------- 1 | package $package; 2 | 3 | import org.tomitribe.crest.val.Exists; 4 | 5 | import javax.validation.ConstraintValidator; 6 | import javax.validation.ConstraintValidatorContext; 7 | import javax.validation.Payload; 8 | import java.io.File; 9 | import java.lang.annotation.Documented; 10 | import java.lang.annotation.Retention; 11 | import java.lang.annotation.Target; 12 | 13 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 14 | import static java.lang.annotation.ElementType.FIELD; 15 | import static java.lang.annotation.ElementType.METHOD; 16 | import static java.lang.annotation.ElementType.PARAMETER; 17 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 18 | 19 | @Exists 20 | @Documented 21 | @javax.validation.Constraint(validatedBy = {IsFile.Constraint.class}) 22 | @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER}) 23 | @Retention(RUNTIME) 24 | public @interface IsFile { 25 | Class[] groups() default {}; 26 | 27 | String message() default "{$groupId.IsFile.message}"; 28 | 29 | Class[] payload() default {}; 30 | 31 | public static class Constraint implements ConstraintValidator { 32 | 33 | @Override 34 | public void initialize(IsFile constraintAnnotation) { 35 | } 36 | 37 | @Override 38 | public boolean isValid(File file, ConstraintValidatorContext context) { 39 | return file.isFile(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /tomitribe-crest-archetype/src/main/resources/archetype-resources/src/test/java/AppTest.java: -------------------------------------------------------------------------------- 1 | package $package; 2 | 3 | 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | import org.tomitribe.crest.Main; 7 | 8 | /** 9 | * Unit test for simple App. 10 | */ 11 | public class AppTest extends Assert { 12 | 13 | @Test 14 | public void testApp() throws Exception { 15 | final Main main = new Main(App.class); 16 | 17 | assertEquals("Hello, World!", main.exec("hello")); 18 | assertEquals("Hello, Wisconsin!", main.exec("hello", "--name=Wisconsin")); 19 | assertEquals("Hola, Ecuador!", main.exec("hello", "--name=Ecuador", "--language=ES")); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tomitribe-crest-arthur-extension/src/main/resources/META-INF/services/org.apache.geronimo.arthur.spi.ArthurExtension: -------------------------------------------------------------------------------- 1 | org.tomitribe.crest.arthur.CrestExtension 2 | -------------------------------------------------------------------------------- /tomitribe-crest-arthur-extension/src/main/resources/META-INF/services/org.graalvm.compiler.options.OptionDescriptors: -------------------------------------------------------------------------------- 1 | org.tomitribe.crest.arthur.feature.CrestFeature$CrestOptions 2 | -------------------------------------------------------------------------------- /tomitribe-crest-cli/src/main/java/org/tomitribe/crest/cli/api/CliEnvironment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cli.api; 18 | 19 | import jline.console.history.History; 20 | import org.tomitribe.crest.environments.Environment; 21 | 22 | import java.util.Map; 23 | 24 | public interface CliEnvironment extends Environment { 25 | History history(); 26 | InputReader reader(); 27 | Map userData(); 28 | } 29 | -------------------------------------------------------------------------------- /tomitribe-crest-cli/src/main/java/org/tomitribe/crest/cli/api/InputReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cli.api; 18 | 19 | import java.io.IOException; 20 | 21 | public interface InputReader extends AutoCloseable { 22 | String readLine(String prompt) throws IOException; 23 | 24 | String readPassword(String prompt) throws IOException; 25 | 26 | void clear(); 27 | } 28 | -------------------------------------------------------------------------------- /tomitribe-crest-cli/src/main/java/org/tomitribe/crest/cli/api/interceptor/interactive/Interactivable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cli.api.interceptor.interactive; 18 | 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.Target; 21 | 22 | import static java.lang.annotation.ElementType.PARAMETER; 23 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 24 | 25 | @Target(PARAMETER) 26 | @Retention(RUNTIME) 27 | public @interface Interactivable { 28 | boolean password() default false; 29 | } 30 | -------------------------------------------------------------------------------- /tomitribe-crest-cli/src/main/java/org/tomitribe/crest/cli/impl/CliEnv.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cli.impl; 18 | 19 | import org.tomitribe.crest.cli.api.CliEnvironment; 20 | import org.tomitribe.crest.environments.SystemEnvironment; 21 | 22 | import java.util.Map; 23 | 24 | public abstract class CliEnv extends SystemEnvironment implements CliEnvironment { 25 | public CliEnv(final Map, Object> services) { 26 | super(services); 27 | } 28 | 29 | public CliEnv() { 30 | super(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tomitribe-crest-generator/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | org.tomitribe.crest.generator.CrestBindingGeneratorProcessor 2 | -------------------------------------------------------------------------------- /tomitribe-crest-test/src/main/java/org/tomitribe/crest/test/Jars.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.test; 18 | 19 | import java.io.File; 20 | import java.io.IOException; 21 | 22 | import static org.tomitribe.util.JarLocation.jarLocation; 23 | 24 | public class Jars { 25 | private Jars() { 26 | } 27 | 28 | public static File jarOf(final Class clazz) { 29 | try { 30 | final File file = jarLocation(clazz); 31 | if (file.isDirectory()) { 32 | return Jar.archive().addDir(file).toJar(); 33 | } 34 | return file; 35 | } catch (IOException e) { 36 | throw new IllegalStateException("Unable to create a jar for class " + clazz.getName(), e); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tomitribe-crest-test/src/test/java/org/tomitribe/crest/test/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.test; 18 | 19 | public class Hello { 20 | 21 | public static void main(String[] args) { 22 | System.out.println("Hello!"); 23 | for (final String arg : args) { 24 | System.out.println("arg: " + arg); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tomitribe-crest-test/src/test/java/org/tomitribe/crest/test/JarTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.test; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | 22 | public class JarTest { 23 | 24 | @Test 25 | public void test() { 26 | final Java.Result result = Jar.mainClass(Hello.class).exec(); 27 | 28 | Assert.assertEquals("", result.getErr()); 29 | Assert.assertEquals("Hello!" + System.lineSeparator(), result.getOut()); 30 | } 31 | 32 | @Test 33 | public void testArguments() { 34 | final Java.Result result = Jar.mainClass(Hello.class) 35 | .exec("red", "green", "blue"); 36 | 37 | Assert.assertEquals("", result.getErr()); 38 | Assert.assertEquals("Hello!" + System.lineSeparator() + 39 | "arg: red" + System.lineSeparator() + 40 | "arg: green" + System.lineSeparator() + 41 | "arg: blue" + System.lineSeparator(), result.getOut()); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /tomitribe-crest-xbean/src/main/java/org/tomitribe/crest/xbean/ClasspathScanner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.xbean; 18 | 19 | import org.apache.xbean.finder.UrlSet; 20 | import org.apache.xbean.finder.archive.Archive; 21 | import org.apache.xbean.finder.archive.ClassesArchive; 22 | import org.apache.xbean.finder.archive.ClasspathArchive; 23 | 24 | import java.io.IOException; 25 | 26 | public class ClasspathScanner extends XbeanScanningLoader { 27 | 28 | public ClasspathScanner() { 29 | super(System.getProperty("java.home") == null ? new ClassesArchive() : ClasspathScanner.defaultArchive()); 30 | } 31 | 32 | private static Archive defaultArchive() { 33 | try { 34 | final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); 35 | 36 | UrlSet urls = new UrlSet(classLoader); 37 | urls = urls.excludeJvm(); 38 | urls = urls.exclude(classLoader.getParent()); 39 | 40 | return new ClasspathArchive(classLoader, urls.getUrls()); 41 | 42 | } catch (final IOException e) { 43 | throw new IllegalStateException(e); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /tomitribe-crest-xbean/src/main/java/org/tomitribe/crest/xbean/UberJarScanner.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.xbean; 18 | 19 | import org.apache.xbean.finder.archive.Archive; 20 | import org.apache.xbean.finder.archive.ClasspathArchive; 21 | import org.tomitribe.util.JarLocation; 22 | 23 | import java.io.File; 24 | import java.net.MalformedURLException; 25 | 26 | public class UberJarScanner extends XbeanScanningLoader { 27 | 28 | public UberJarScanner() { 29 | super(UberJarScanner.defaultArchive()); 30 | } 31 | 32 | private static Archive defaultArchive() { 33 | try { 34 | final Class reference = UberJarScanner.class; 35 | 36 | final File file = JarLocation.jarLocation(reference); 37 | return ClasspathArchive.archive(reference.getClassLoader(), file.toURI().toURL()); 38 | } catch (final MalformedURLException e) { 39 | throw new IllegalStateException(e); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /tomitribe-crest-xbean/src/main/java/org/tomitribe/crest/xbean/XbeanScanningLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.xbean; 18 | 19 | import org.apache.xbean.finder.AnnotationFinder; 20 | import org.apache.xbean.finder.archive.Archive; 21 | import org.tomitribe.crest.BashCompletion; 22 | import org.tomitribe.crest.cmds.processors.Commands; 23 | import org.tomitribe.crest.api.Command; 24 | 25 | import java.lang.reflect.Method; 26 | import java.util.HashSet; 27 | import java.util.Iterator; 28 | import java.util.Set; 29 | 30 | public abstract class XbeanScanningLoader implements Commands.Loader { 31 | final Set> classes = new HashSet<>(); 32 | 33 | public XbeanScanningLoader(final Archive archive) { 34 | final AnnotationFinder finder = new AnnotationFinder(archive); 35 | 36 | for (final Method method : finder.findAnnotatedMethods(Command.class)) { 37 | classes.add(method.getDeclaringClass()); 38 | } 39 | classes.remove(BashCompletion.class); 40 | } 41 | 42 | 43 | @Override 44 | public Iterator> iterator() { 45 | return classes.iterator(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tomitribe-crest-xbean/src/main/resources/META-INF/NOTICE: -------------------------------------------------------------------------------- 1 | Tomitribe :: Crest XBean Finder Scanning 2 | Copyright 2014 Tomitribe Corporation 3 | 4 | This product includes software developed at 5 | Tomitribe Corporation (http://www.tomitribe.com/). 6 | 7 | 8 | -------------------------------------------------------------------------------- /tomitribe-crest-xbean/src/main/resources/META-INF/services/org.tomitribe.crest.cmds.processors.Commands$Loader: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | org.tomitribe.crest.xbean.ClasspathScanner 19 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/Exec.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest; 18 | 19 | /** 20 | * Flavor of Main that does not call System.exit making it 21 | * useful in server environments and exec-maven-plugin friendly 22 | */ 23 | public class Exec { 24 | 25 | private Exec() { 26 | } 27 | 28 | public static void main(final String... args) throws Exception { 29 | Main.builder() 30 | .noexit() 31 | .build() 32 | .run(args); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/cmds/Cmd.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cmds; 18 | 19 | import org.tomitribe.crest.interceptor.internal.InternalInterceptor; 20 | 21 | import java.io.PrintStream; 22 | import java.util.Map; 23 | 24 | public interface Cmd extends Completer { 25 | String getUsage(); 26 | 27 | String getName(); 28 | 29 | Object exec(Map, InternalInterceptor> globalInterceptors, String... rawArgs); 30 | 31 | void help(PrintStream out); 32 | 33 | default void manual(PrintStream out) { 34 | help(out); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/cmds/CommandFailedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cmds; 18 | 19 | public class CommandFailedException extends RuntimeException { 20 | 21 | private final String name; 22 | 23 | public CommandFailedException(Throwable cause, String name) { 24 | super(cause); 25 | this.name = name; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/cmds/Completer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cmds; 18 | 19 | import java.util.Collection; 20 | 21 | public interface Completer { 22 | public abstract Collection complete(String buffer, int cursorPosition); 23 | } 24 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/cmds/HelpPrintedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cmds; 18 | 19 | import org.tomitribe.crest.api.Exit; 20 | 21 | /** 22 | * We have a slightly unintuitive error handling scheme (my bad) 23 | * that prints help early and then suppresses printing error 24 | * messages and stacktraces in exception handling later in the call 25 | * stack. The intention is that the message has already been printed 26 | * along with full help output, so don't print the message again later. 27 | * 28 | * Unfortunately, it results in some valid exceptions never being printed 29 | * and Crest silently failing with no help or output of any kind. 30 | * 31 | * The creation of this class is an attempt to make it explicit when we 32 | * have in fact printed help eagerly. 33 | * 34 | * The exception type that implied this before was IllegalStateException, 35 | * which is unfortunately very common in the vm and was getting thrown 36 | * outside our handling and suppressed. 37 | */ 38 | @Exit(10) 39 | public class HelpPrintedException extends IllegalArgumentException { 40 | public HelpPrintedException(final Throwable throwable) { 41 | super(throwable); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/cmds/MissingArgumentException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cmds; 18 | 19 | import org.tomitribe.crest.api.Exit; 20 | 21 | @Exit(value = 400, help = true) // using http status codes because it's fun :) 22 | public class MissingArgumentException extends IllegalArgumentException { 23 | public MissingArgumentException(final String s) { 24 | super("Missing argument: " + s + ""); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/cmds/targets/Target.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.cmds.targets; 18 | 19 | import java.lang.reflect.InvocationTargetException; 20 | import java.lang.reflect.Method; 21 | 22 | public interface Target { 23 | Object invoke(Method method, Object... args) throws InvocationTargetException, IllegalAccessException; 24 | 25 | Object getInstance(Method method); 26 | } 27 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/contexts/DefaultsContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.contexts; 18 | 19 | import org.tomitribe.crest.cmds.targets.Target; 20 | 21 | import java.lang.reflect.Method; 22 | 23 | /** 24 | * Used to provide substitution values for @Default("hello ${value}") type expressions. 25 | */ 26 | public interface DefaultsContext { 27 | /** 28 | * Implementations of DefaultsContext need to implement this method to convert 29 | * an expression inside ${...} type substitutions to String values which will 30 | * replace the substitution expression. 31 | * 32 | * @param target The command class 33 | * @param commandMethod the command method 34 | * @param key the ... in the ${...} expression 35 | * @return the value to replace key with. Null is equivalent to the empty string. 36 | */ 37 | public String find(Target target, Method commandMethod, String key); 38 | } 39 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/contexts/EnvDefaultsContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.contexts; 18 | 19 | import java.lang.reflect.Method; 20 | 21 | import org.tomitribe.crest.cmds.targets.Target; 22 | 23 | public class EnvDefaultsContext implements DefaultsContext { 24 | @Override 25 | public String find(final Target cmd, final Method commandMethod, final String key) { 26 | return System.getenv(key); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/contexts/SystemPropertiesDefaultsContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.tomitribe.crest.contexts; 19 | 20 | import org.tomitribe.crest.cmds.targets.Target; 21 | 22 | import java.lang.reflect.Method; 23 | 24 | public class SystemPropertiesDefaultsContext implements DefaultsContext { 25 | @Override 26 | public String find(final Target cmd, final Method commandMethod, final String key) { 27 | return System.getProperty(key); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/environments/Environment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.environments; 18 | 19 | import java.io.InputStream; 20 | import java.io.PrintStream; 21 | import java.util.Map; 22 | import java.util.Properties; 23 | 24 | public interface Environment { 25 | 26 | ThreadLocal ENVIRONMENT_THREAD_LOCAL = new ThreadLocal() { 27 | @Override 28 | protected Environment initialValue() { 29 | return new SystemEnvironment(); 30 | } 31 | }; 32 | 33 | static Environment get() { 34 | return ENVIRONMENT_THREAD_LOCAL.get(); 35 | } 36 | 37 | static Environment set(final Environment environment) { 38 | final Environment old = ENVIRONMENT_THREAD_LOCAL.get(); 39 | ENVIRONMENT_THREAD_LOCAL.set(environment); 40 | return old; 41 | } 42 | 43 | PrintStream getOutput(); 44 | 45 | PrintStream getError(); 46 | 47 | InputStream getInput(); 48 | 49 | Properties getProperties(); 50 | 51 | default Map getEnv() { 52 | return System.getenv(); 53 | } 54 | 55 | T findService(Class type); 56 | 57 | default String getCommandName() { 58 | return null; 59 | } 60 | 61 | default String getCommandVersion() { 62 | return null; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/Bullet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | public class Bullet implements Element { 20 | private final String content; 21 | 22 | public Bullet(final String content) { 23 | this.content = content.trim(); 24 | } 25 | 26 | @Override 27 | public String getContent() { 28 | return content; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Bullet{" + 34 | "content='" + content + '\'' + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/Element.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | public interface Element { 20 | String getContent(); 21 | } 22 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/Heading.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | public class Heading implements Element { 20 | private final String content; 21 | 22 | public Heading(final String content) { 23 | this.content = content.trim(); 24 | } 25 | 26 | @Override 27 | public String getContent() { 28 | return content; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Heading{" + 34 | "content='" + content + '\'' + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/HtmlDocumentParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | public class HtmlDocumentParser { 20 | 21 | public static Document parse(final String content) { 22 | return null; 23 | } 24 | 25 | private HtmlDocumentParser() { 26 | } 27 | 28 | static boolean isHtml(final String content) { 29 | if (content == null) return false; 30 | if (content.contains("
")) return true; 31 | if (content.contains("
")) return true; 32 | if (content.contains("
")) return true; 33 | if (content.contains("

")) return true; 34 | if (content.contains("

")) return true; 35 | if (content.contains("

")) return true; 36 | if (content.contains("

")) return true; 37 | if (content.contains("

")) return true; 38 | if (content.contains("

")) return true; 39 | return false; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/IllegalElementException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | import javax.lang.model.element.ExecutableElement; 20 | 21 | public class IllegalElementException extends RuntimeException { 22 | public IllegalElementException(final String s, final ExecutableElement executableElement) { 23 | this(s, executableElement, null); 24 | } 25 | 26 | public IllegalElementException(final String s, final ExecutableElement executableElement, final Throwable t) { 27 | super(String.format("%s: class %s, method %s", 28 | s, 29 | executableElement.getEnclosingElement(), 30 | executableElement.getSimpleName() 31 | ), t); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/InvalidJavadocFileException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | import java.io.IOException; 20 | 21 | public class InvalidJavadocFileException extends IllegalStateException { 22 | public InvalidJavadocFileException(final String resourceFileName, final IOException e) { 23 | super("Unable to read javadoc from store file: " + resourceFileName, e); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | public class Option implements Element { 20 | private final String flag; 21 | private final Document document; 22 | 23 | public Option(final String flag, final Document document) { 24 | this.flag = flag; 25 | this.document = document; 26 | } 27 | 28 | public String getFlag() { 29 | return flag; 30 | } 31 | 32 | public Document getDocument() { 33 | return document; 34 | } 35 | 36 | @Override 37 | public String getContent() { 38 | return null; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "Option{" + 44 | "flag='" + flag + '\'' + 45 | '}'; 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/Paragraph.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | public class Paragraph implements Element { 20 | 21 | private final String content; 22 | 23 | public String getContent() { 24 | return content; 25 | } 26 | 27 | public Paragraph(final String content) { 28 | this.content = content.trim(); 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Paragraph{" + 34 | "content='" + content + '\'' + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/help/Preformatted.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | public class Preformatted implements Element { 20 | private final String content; 21 | 22 | public Preformatted(final String content) { 23 | this.content = content; 24 | } 25 | 26 | @Override 27 | public String getContent() { 28 | return content; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Preformatted{" + 34 | "content='" + content + '\'' + 35 | '}'; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/interceptor/InterceptorAnnotationNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Tomitribe and community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.tomitribe.crest.interceptor; 17 | 18 | public class InterceptorAnnotationNotFoundException extends IllegalStateException { 19 | public InterceptorAnnotationNotFoundException(final Class clazz) { 20 | super("@CrestInterceptor not found on any methods of class " + clazz.getName() + ". " + 21 | "Expecting a method declaration like the following:\n" + 22 | " @CrestInterceptor\n" + 23 | " public Object intercept(final CrestContext crestContext) {\n" + 24 | " // do something fun\n" + 25 | " return crestContext.proceed();\n" + 26 | " }\n"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/interceptor/UnresolvedInterceptorAnnotationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Tomitribe and community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.tomitribe.crest.interceptor; 17 | 18 | import org.tomitribe.crest.api.Loader; 19 | 20 | public class UnresolvedInterceptorAnnotationException extends IllegalStateException { 21 | public UnresolvedInterceptorAnnotationException(final Class interceptorClass) { 22 | super(message(interceptorClass)); 23 | } 24 | 25 | private static String message(final Class interceptorClass) { 26 | return String.format("Custom interceptor annotation @%s did not resolve. " + 27 | "Please ensure the implementing class is returned by a %s and is" + 28 | " also annotated with @%s", interceptorClass.getName(), Loader.class.getName(), interceptorClass.getSimpleName()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/interceptor/security/RoleProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.interceptor.security; 18 | 19 | public interface RoleProvider { 20 | boolean hasRole(String role); 21 | } 22 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/interceptor/security/SecurityInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.interceptor.security; 18 | 19 | import org.tomitribe.crest.api.interceptor.CrestContext; 20 | import org.tomitribe.crest.api.interceptor.CrestInterceptor; 21 | import org.tomitribe.crest.environments.Environment; 22 | 23 | import javax.annotation.security.RolesAllowed; 24 | 25 | public class SecurityInterceptor { 26 | @CrestInterceptor 27 | public Object secure(final CrestContext crestContext) { 28 | final RolesAllowed rolesAllowed = crestContext.getMethod().getAnnotation(RolesAllowed.class); 29 | if (rolesAllowed != null) { 30 | final RoleProvider provider = Environment.ENVIRONMENT_THREAD_LOCAL.get().findService(RoleProvider.class); 31 | if (provider == null) { 32 | throw new IllegalStateException("No RoleProvider registered, security interceptor can't work."); 33 | } 34 | for (final String role : rolesAllowed.value()) { 35 | if (provider.hasRole(role)) { 36 | return crestContext.proceed(); 37 | } 38 | } 39 | throw new IllegalArgumentException("User is not allowed to perform this operation"); 40 | } 41 | return crestContext.proceed(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/table/Lines.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.table; 18 | 19 | import org.tomitribe.util.Join; 20 | 21 | import java.util.List; 22 | import java.util.regex.Pattern; 23 | 24 | public class Lines { 25 | 26 | private Lines() { 27 | } 28 | 29 | private static final Pattern separator = Pattern.compile(" *" + System.lineSeparator()); 30 | 31 | public static String[] split(final String string) { 32 | return separator.split(string); 33 | } 34 | 35 | public static String join(final List list) { 36 | return Join.join(System.lineSeparator(), list); 37 | } 38 | 39 | public static String join(final Object... list) { 40 | return Join.join(System.lineSeparator(), list); 41 | } 42 | 43 | public static String center(final String string, final int width) { 44 | final StringBuilder builder = new StringBuilder(width); 45 | builder.append(string); 46 | while (builder.length() < width) { 47 | builder.append(" "); 48 | 49 | if (builder.length() < width) { 50 | builder.insert(0, " "); 51 | } 52 | } 53 | return builder.toString(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/table/TableInterceptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Tomitribe and community 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.tomitribe.crest.table; 17 | 18 | import org.tomitribe.crest.api.interceptor.CrestContext; 19 | import org.tomitribe.crest.api.interceptor.CrestInterceptor; 20 | import org.tomitribe.crest.api.table.Table; 21 | 22 | import java.util.Arrays; 23 | import java.util.List; 24 | import java.util.stream.Collectors; 25 | import java.util.stream.Stream; 26 | 27 | @Table 28 | public class TableInterceptor { 29 | 30 | @CrestInterceptor 31 | public Object intercept(final CrestContext crestContext) { 32 | 33 | final Object result = crestContext.proceed(); 34 | 35 | final Options options = Options.from(crestContext); 36 | 37 | if (result instanceof Iterable) { 38 | final Iterable list = (Iterable) result; 39 | return new TableOutput(list, options); 40 | } 41 | 42 | if (result instanceof Stream) { 43 | final Stream stream = (Stream) result; 44 | final List list = stream.collect(Collectors.toList()); 45 | return new TableOutput(list, options); 46 | } 47 | 48 | if (result != null && result.getClass().isArray()) { 49 | final List list = Arrays.asList((Object[]) result); 50 | return new TableOutput(list, options); 51 | } 52 | 53 | return result; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/BeanValidation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import java.util.function.Function; 20 | 21 | /** 22 | * A simple interceptor to validate parameters and returned value using 23 | * bean validation spec. It doesn't use group for now. 24 | */ 25 | public class BeanValidation { 26 | private BeanValidation() { 27 | // no-op 28 | } 29 | 30 | public static BeanValidationImpl create(final Function, Object> validatorLookup) { 31 | BeanValidationImpl impl = null; 32 | final ClassLoader loader = BeanValidation.class.getClassLoader(); 33 | try { 34 | Class.forName("javax.validation.executable.ExecutableValidator", false, loader); 35 | impl = new BeanValidation11(); 36 | } catch (final ClassNotFoundException e) { 37 | try { 38 | Class.forName("org.apache.bval.jsr303.extensions.MethodValidator", false, loader); 39 | impl = new BVal05(); 40 | } catch (final ClassNotFoundException cnfe) { 41 | // no-op 42 | } 43 | } 44 | return new BuiltInValidation(impl, validatorLookup); 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/BeanValidationImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import java.lang.reflect.Constructor; 20 | import java.lang.reflect.Method; 21 | import java.util.List; 22 | import java.util.Optional; 23 | 24 | public interface BeanValidationImpl { 25 | void validateParameters(Object instanceOrClass, Method method, Object[] parameters); 26 | 27 | void validateParameters(Constructor constructor, Object[] parameters); 28 | 29 | Optional> messages(Throwable exception); 30 | } -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/BeanValidationMessages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import javax.validation.ConstraintViolation; 20 | import javax.validation.ConstraintViolationException; 21 | import java.util.List; 22 | import java.util.Optional; 23 | 24 | import static java.util.stream.Collectors.toList; 25 | 26 | abstract class BeanValidationMessages implements BeanValidationImpl { 27 | @Override 28 | public Optional> messages(final Throwable exception) { 29 | return Optional.of(exception) 30 | .filter(ConstraintViolationException.class::isInstance) 31 | .map(ConstraintViolationException.class::cast) 32 | .map(cve -> cve.getConstraintViolations().stream().map(ConstraintViolation::getMessage).collect(toList())); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/ConstraintAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import javax.validation.ConstraintValidator; 20 | import javax.validation.ConstraintValidatorContext; 21 | import java.lang.annotation.Annotation; 22 | 23 | /** 24 | * @version $Revision$ $Date$ 25 | */ 26 | public class ConstraintAdapter implements ConstraintValidator { 27 | @Override 28 | public void initialize(final A constraintAnnotation) { 29 | } 30 | 31 | @Override 32 | public boolean isValid(final T value, final ConstraintValidatorContext context) { 33 | return isValid(value); 34 | } 35 | 36 | public boolean isValid(final T value) { 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/Directory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import javax.validation.Payload; 20 | import java.io.File; 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 26 | import static java.lang.annotation.ElementType.FIELD; 27 | import static java.lang.annotation.ElementType.METHOD; 28 | import static java.lang.annotation.ElementType.PARAMETER; 29 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 30 | 31 | @Exists 32 | @Documented 33 | @javax.validation.Constraint(validatedBy = {Directory.Constraint.class}) 34 | @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER}) 35 | @Retention(RUNTIME) 36 | public @interface Directory { 37 | Class[] groups() default {}; 38 | 39 | String message() default "{org.tomitribe.crest.val.Directory.message}"; 40 | 41 | Class[] payload() default {}; 42 | 43 | public static class Constraint extends ConstraintAdapter { 44 | @Override 45 | public boolean isValid(final File value) { 46 | return value.isDirectory(); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/Executable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import javax.validation.Payload; 20 | import java.io.File; 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 26 | import static java.lang.annotation.ElementType.FIELD; 27 | import static java.lang.annotation.ElementType.METHOD; 28 | import static java.lang.annotation.ElementType.PARAMETER; 29 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 30 | 31 | @Documented 32 | @javax.validation.Constraint(validatedBy = {Executable.Constraint.class}) 33 | @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER}) 34 | @Retention(RUNTIME) 35 | public @interface Executable { 36 | Class[] groups() default {}; 37 | 38 | String message() default "{org.tomitribe.crest.val.Executable.message}"; 39 | 40 | Class[] payload() default {}; 41 | 42 | public static class Constraint extends ConstraintAdapter { 43 | @Override 44 | public boolean isValid(final File value) { 45 | return value.canExecute(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/Exists.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import javax.validation.Payload; 20 | import java.io.File; 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 26 | import static java.lang.annotation.ElementType.FIELD; 27 | import static java.lang.annotation.ElementType.METHOD; 28 | import static java.lang.annotation.ElementType.PARAMETER; 29 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 30 | 31 | @Documented 32 | @javax.validation.Constraint(validatedBy = {Exists.Constraint.class}) 33 | @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER}) 34 | @Retention(RUNTIME) 35 | public @interface Exists { 36 | Class[] groups() default {}; 37 | 38 | String message() default "{org.tomitribe.crest.val.Exists.message}"; 39 | 40 | Class[] payload() default {}; 41 | 42 | public static class Constraint extends ConstraintAdapter { 43 | @Override 44 | public boolean isValid(final File value) { 45 | return value.exists(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/Readable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import javax.validation.Payload; 20 | import java.io.File; 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 26 | import static java.lang.annotation.ElementType.FIELD; 27 | import static java.lang.annotation.ElementType.METHOD; 28 | import static java.lang.annotation.ElementType.PARAMETER; 29 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 30 | 31 | @Documented 32 | @javax.validation.Constraint(validatedBy = {Readable.Constraint.class}) 33 | @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER}) 34 | @Retention(RUNTIME) 35 | public @interface Readable { 36 | Class[] groups() default {}; 37 | 38 | String message() default "{org.tomitribe.crest.val.Readable.message}"; 39 | 40 | Class[] payload() default {}; 41 | 42 | public static class Constraint extends ConstraintAdapter { 43 | @Override 44 | public boolean isValid(final File value) { 45 | return value.canRead(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/java/org/tomitribe/crest/val/Writable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.val; 18 | 19 | import javax.validation.Payload; 20 | import java.io.File; 21 | import java.lang.annotation.Documented; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 26 | import static java.lang.annotation.ElementType.FIELD; 27 | import static java.lang.annotation.ElementType.METHOD; 28 | import static java.lang.annotation.ElementType.PARAMETER; 29 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 30 | 31 | @Documented 32 | @javax.validation.Constraint(validatedBy = {Writable.Constraint.class}) 33 | @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER}) 34 | @Retention(RUNTIME) 35 | public @interface Writable { 36 | Class[] groups() default {}; 37 | 38 | String message() default "{org.tomitribe.crest.val.Writable.message}"; 39 | 40 | Class[] payload() default {}; 41 | 42 | public static class Constraint extends ConstraintAdapter { 43 | @Override 44 | public boolean isValid(final File value) { 45 | return value.canWrite(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/resources/META-INF/NOTICE: -------------------------------------------------------------------------------- 1 | Tomitribe :: Crest 2 | Copyright 2014 Tomitribe Corporation 3 | 4 | This product includes software developed at 5 | Tomitribe Corporation (http://www.tomitribe.com/). 6 | 7 | 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/resources/ValidationMessages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | org.tomitribe.crest.val.Readable.message = Not readable 19 | org.tomitribe.crest.val.Writable.message = Not writable 20 | org.tomitribe.crest.val.Exists.message = Does not exist 21 | org.tomitribe.crest.val.Directory.message = Not a directory 22 | org.tomitribe.crest.val.Executable.message = Not executable 23 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/resources/ValidationMessages_en.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | -------------------------------------------------------------------------------- /tomitribe-crest/src/main/resources/ValidationMessages_pt_BR.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | org.tomitribe.crest.val.Readable.message = Não pode ser lido 19 | org.tomitribe.crest.val.Writable.message = Não pode ser escrito 20 | org.tomitribe.crest.val.Exists.message = Não existe 21 | org.tomitribe.crest.val.Directory.message = Não é diretório 22 | org.tomitribe.crest.val.Executable.message = Não é executável -------------------------------------------------------------------------------- /tomitribe-crest/src/test/java/org/tomitribe/crest/Archives.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed under the Apache License, Version 2.0 (the "License"); 3 | * you may not use this file except in compliance with the License. 4 | * You may obtain a copy of the License at 5 | * 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software 9 | * distributed under the License is distributed on an "AS IS" BASIS, 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | * See the License for the specific language governing permissions and 12 | * limitations under the License. 13 | */ 14 | package org.tomitribe.crest; 15 | 16 | import org.tomitribe.util.Archive; 17 | 18 | import java.net.MalformedURLException; 19 | import java.net.URL; 20 | import java.net.URLClassLoader; 21 | import java.util.stream.Stream; 22 | 23 | public class Archives { 24 | public static ClassLoader classLoader(final Archive... archives) { 25 | final URL[] urls = Stream.of(archives) 26 | .map(Archive::asJar) 27 | .map(file -> { 28 | try { 29 | return file.toURI().toURL(); 30 | } catch (final MalformedURLException e) { 31 | throw new RuntimeException(e); 32 | } 33 | }).toArray(URL[]::new); 34 | 35 | return new URLClassLoader(urls); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/java/org/tomitribe/crest/Foo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest; 18 | 19 | /** 20 | * @version $Revision$ $Date$ 21 | */ 22 | public class Foo { 23 | } 24 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/java/org/tomitribe/crest/MissingArgumentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | import org.tomitribe.crest.api.Command; 22 | import org.tomitribe.crest.api.Loader; 23 | import org.tomitribe.crest.test.Java; 24 | 25 | import java.util.Iterator; 26 | 27 | public class MissingArgumentTest { 28 | 29 | @Test 30 | public void missingArgument() { 31 | 32 | final Java.Result result = Crest.jar() 33 | .command(Greeting.class) 34 | .exec("hello"); 35 | 36 | Assert.assertEquals("Missing argument: String\n" + 37 | "\n" + 38 | "Usage: hello String\n" + 39 | "\n", result.getErr()); 40 | } 41 | 42 | 43 | public static class Greeting { 44 | @Command 45 | public String hello(final String name) { 46 | return String.format("Hello, %s!", name); 47 | } 48 | } 49 | 50 | public static class Commands implements Loader { 51 | @Override 52 | public Iterator> iterator() { 53 | return Loader.of(Greeting.class); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/java/org/tomitribe/crest/VarargStreamTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest; 18 | 19 | import org.junit.Test; 20 | import org.tomitribe.crest.api.Command; 21 | import org.tomitribe.crest.api.In; 22 | import org.tomitribe.crest.api.Option; 23 | import org.tomitribe.crest.api.Out; 24 | 25 | import java.io.InputStream; 26 | import java.io.PrintStream; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | 30 | public class VarargStreamTest { 31 | @Test 32 | public void run() throws Exception { 33 | assertEquals("123truetrue", new Main(TheCmd.class).exec("root", "result", "--some=1", "--other=2", "3")); 34 | assertEquals("1234truetrue", new Main(TheCmd.class).exec("root", "result", "--some=1", "--other=2", "3", "4")); 35 | } 36 | 37 | @Command("root") 38 | public static class TheCmd { 39 | @Command 40 | public static String result(@Option("some") final String some, 41 | @Option("other") final String other, 42 | @In final InputStream in, 43 | @Out final PrintStream out, 44 | final String[] value) { 45 | return some + other + value[0] + (value.length > 1 ? value[1] : "") + (in != null) + (out != null); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/java/org/tomitribe/crest/help/DocumentFormatterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.tomitribe.crest.help; 18 | 19 | import org.junit.Assert; 20 | import org.junit.Test; 21 | import org.tomitribe.util.IO; 22 | 23 | import java.io.IOException; 24 | import java.net.URL; 25 | 26 | public class DocumentFormatterTest { 27 | 28 | 29 | @Test 30 | public void formatWidth86() throws Exception { 31 | assertWidth(86); 32 | } 33 | 34 | @Test 35 | public void formatWidth178() throws Exception { 36 | assertWidth(178); 37 | } 38 | 39 | @Test 40 | public void formatWidth106() throws Exception { 41 | assertWidth(106); 42 | } 43 | 44 | public void assertWidth(final int width) throws IOException { 45 | final Document document = RsyncManPage.getDocument(); 46 | 47 | final DocumentFormatter documentFormatter = new DocumentFormatter(width, false); 48 | final String actual = documentFormatter.format(document); 49 | 50 | document.getElements(); 51 | final ClassLoader loader = this.getClass().getClassLoader(); 52 | final URL resource = loader.getResource("man/expected-" + width + ".txt"); 53 | final String expected = IO.slurp(resource); 54 | 55 | Assert.assertEquals(expected, actual.replaceAll("\r\n","\n")); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/asciiCompact.txt: -------------------------------------------------------------------------------- 1 | 9 Apache TomEE 2016-05-17 7.0.x 2 | 523456789 Tomcat 2018-01-17 9.0.x 3 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/asciiDots.txt: -------------------------------------------------------------------------------- 1 | ............................................................. 2 | : 9 : Apache TomEE : 2016-05-17 : 7.0.x : 3 | : 523456789 : Tomcat : 2018-01-17 : 9.0.x : 4 | : 14 : Apache ActiveMQ Classic : 2022-03-09 : 5.17.x : 5 | :...........:.........................:............:........: 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/asciiSeparated.txt: -------------------------------------------------------------------------------- 1 | +===========+=========================+============+========+ 2 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 3 | +-----------+-------------------------+------------+--------+ 4 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 5 | +-----------+-------------------------+------------+--------+ 6 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 7 | +-----------+-------------------------+------------+--------+ 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/githubMarkdown.txt: -------------------------------------------------------------------------------- 1 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 2 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 3 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/mysqlStyle.txt: -------------------------------------------------------------------------------- 1 | +-----------+-------------------------+------------+--------+ 2 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 3 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 4 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 5 | +-----------+-------------------------+------------+--------+ 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/reStructuredTextGrid.txt: -------------------------------------------------------------------------------- 1 | +-----------+-------------------------+------------+--------+ 2 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 3 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 4 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 5 | +-----------+-------------------------+------------+--------+ 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/reStructuredTextSimple.txt: -------------------------------------------------------------------------------- 1 | =========== ========================= ============ ======== 2 | 9 Apache TomEE 2016-05-17 7.0.x 3 | 523456789 Tomcat 2018-01-17 9.0.x 4 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 5 | =========== ========================= ============ ======== 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/redditMarkdown.txt: -------------------------------------------------------------------------------- 1 | 9 | Apache TomEE | 2016-05-17 | 7.0.x 2 | 523456789 | Tomcat | 2018-01-17 | 9.0.x 3 | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/unicodeDouble.txt: -------------------------------------------------------------------------------- 1 | ╔═══════════╦═════════════════════════╦════════════╦════════╗ 2 | ║ 9 ║ Apache TomEE ║ 2016-05-17 ║ 7.0.x ║ 3 | ║ 523456789 ║ Tomcat ║ 2018-01-17 ║ 9.0.x ║ 4 | ║ 14 ║ Apache ActiveMQ Classic ║ 2022-03-09 ║ 5.17.x ║ 5 | ╚═══════════╩═════════════════════════╩════════════╩════════╝ 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/unicodeSingle.txt: -------------------------------------------------------------------------------- 1 | ┌───────────┬─────────────────────────┬────────────┬────────┐ 2 | │ 9 │ Apache TomEE │ 2016-05-17 │ 7.0.x │ 3 | │ 523456789 │ Tomcat │ 2018-01-17 │ 9.0.x │ 4 | │ 14 │ Apache ActiveMQ Classic │ 2022-03-09 │ 5.17.x │ 5 | └───────────┴─────────────────────────┴────────────┴────────┘ 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/unicodeSingleSeparated.txt: -------------------------------------------------------------------------------- 1 | ┌───────────┬─────────────────────────┬────────────┬────────┐ 2 | │ 9 │ Apache TomEE │ 2016-05-17 │ 7.0.x │ 3 | ├───────────┼─────────────────────────┼────────────┼────────┤ 4 | │ 523456789 │ Tomcat │ 2018-01-17 │ 9.0.x │ 5 | ├───────────┼─────────────────────────┼────────────┼────────┤ 6 | │ 14 │ Apache ActiveMQ Classic │ 2022-03-09 │ 5.17.x │ 7 | └───────────┴─────────────────────────┴────────────┴────────┘ 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/whitespaceCompact.txt: -------------------------------------------------------------------------------- 1 | 9 Apache TomEE 2016-05-17 7.0.x 2 | 523456789 Tomcat 2018-01-17 9.0.x 3 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderNoHeaderTest/whitespaceSeparated.txt: -------------------------------------------------------------------------------- 1 | 9 Apache TomEE 2016-05-17 7.0.x 2 | 3 | 523456789 Tomcat 2018-01-17 9.0.x 4 | 5 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/asciiCompact.txt: -------------------------------------------------------------------------------- 1 | id project releaseDate version 2 | ----------- ------------------------- ------------- --------- 3 | 9 Apache TomEE 2016-05-17 7.0.x 4 | 523456789 Tomcat 2018-01-17 9.0.x 5 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/asciiDots.txt: -------------------------------------------------------------------------------- 1 | ............................................................... 2 | : id : project : releaseDate : version : 3 | :...........:.........................:.............:.........: 4 | : 9 : Apache TomEE : 2016-05-17 : 7.0.x : 5 | : 523456789 : Tomcat : 2018-01-17 : 9.0.x : 6 | : 14 : Apache ActiveMQ Classic : 2022-03-09 : 5.17.x : 7 | :...........:.........................:.............:.........: 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/asciiSeparated.txt: -------------------------------------------------------------------------------- 1 | +===========+=========================+=============+=========+ 2 | | id | project | releaseDate | version | 3 | +===========+=========================+=============+=========+ 4 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 5 | +-----------+-------------------------+-------------+---------+ 6 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 7 | +-----------+-------------------------+-------------+---------+ 8 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 9 | +-----------+-------------------------+-------------+---------+ 10 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/githubMarkdown.txt: -------------------------------------------------------------------------------- 1 | | id | project | releaseDate | version | 2 | |-----------|-------------------------|-------------|---------| 3 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 4 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 5 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/mysqlStyle.txt: -------------------------------------------------------------------------------- 1 | +-----------+-------------------------+-------------+---------+ 2 | | id | project | releaseDate | version | 3 | +-----------+-------------------------+-------------+---------+ 4 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 5 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 6 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 7 | +-----------+-------------------------+-------------+---------+ 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/reStructuredTextGrid.txt: -------------------------------------------------------------------------------- 1 | +-----------+-------------------------+-------------+---------+ 2 | | id | project | releaseDate | version | 3 | +===========+=========================+=============+=========+ 4 | | 9 | Apache TomEE | 2016-05-17 | 7.0.x | 5 | | 523456789 | Tomcat | 2018-01-17 | 9.0.x | 6 | | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x | 7 | +-----------+-------------------------+-------------+---------+ 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/reStructuredTextSimple.txt: -------------------------------------------------------------------------------- 1 | =========== ========================= ============= ========= 2 | id project releaseDate version 3 | =========== ========================= ============= ========= 4 | 9 Apache TomEE 2016-05-17 7.0.x 5 | 523456789 Tomcat 2018-01-17 9.0.x 6 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 7 | =========== ========================= ============= ========= 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/redditMarkdown.txt: -------------------------------------------------------------------------------- 1 | id | project | releaseDate | version 2 | -----------|-------------------------|-------------|--------- 3 | 9 | Apache TomEE | 2016-05-17 | 7.0.x 4 | 523456789 | Tomcat | 2018-01-17 | 9.0.x 5 | 14 | Apache ActiveMQ Classic | 2022-03-09 | 5.17.x 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/unicodeDouble.txt: -------------------------------------------------------------------------------- 1 | ╔═══════════╦═════════════════════════╦═════════════╦═════════╗ 2 | ║ id ║ project ║ releaseDate ║ version ║ 3 | ╠═══════════╬═════════════════════════╬═════════════╬═════════╣ 4 | ║ 9 ║ Apache TomEE ║ 2016-05-17 ║ 7.0.x ║ 5 | ║ 523456789 ║ Tomcat ║ 2018-01-17 ║ 9.0.x ║ 6 | ║ 14 ║ Apache ActiveMQ Classic ║ 2022-03-09 ║ 5.17.x ║ 7 | ╚═══════════╩═════════════════════════╩═════════════╩═════════╝ 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/unicodeSingle.txt: -------------------------------------------------------------------------------- 1 | ┌───────────┬─────────────────────────┬─────────────┬─────────┐ 2 | │ id │ project │ releaseDate │ version │ 3 | ├───────────┼─────────────────────────┼─────────────┼─────────┤ 4 | │ 9 │ Apache TomEE │ 2016-05-17 │ 7.0.x │ 5 | │ 523456789 │ Tomcat │ 2018-01-17 │ 9.0.x │ 6 | │ 14 │ Apache ActiveMQ Classic │ 2022-03-09 │ 5.17.x │ 7 | └───────────┴─────────────────────────┴─────────────┴─────────┘ 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/unicodeSingleSeparated.txt: -------------------------------------------------------------------------------- 1 | ┌───────────┬─────────────────────────┬─────────────┬─────────┐ 2 | │ id │ project │ releaseDate │ version │ 3 | ├═══════════┼═════════════════════════┼═════════════┼═════════┤ 4 | │ 9 │ Apache TomEE │ 2016-05-17 │ 7.0.x │ 5 | ├───────────┼─────────────────────────┼─────────────┼─────────┤ 6 | │ 523456789 │ Tomcat │ 2018-01-17 │ 9.0.x │ 7 | ├───────────┼─────────────────────────┼─────────────┼─────────┤ 8 | │ 14 │ Apache ActiveMQ Classic │ 2022-03-09 │ 5.17.x │ 9 | └───────────┴─────────────────────────┴─────────────┴─────────┘ 10 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/whitespaceCompact.txt: -------------------------------------------------------------------------------- 1 | id project releaseDate version 2 | 3 | 9 Apache TomEE 2016-05-17 7.0.x 4 | 523456789 Tomcat 2018-01-17 9.0.x 5 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/TableBorderTest/whitespaceSeparated.txt: -------------------------------------------------------------------------------- 1 | id project releaseDate version 2 | 3 | 9 Apache TomEE 2016-05-17 7.0.x 4 | 5 | 523456789 Tomcat 2018-01-17 9.0.x 6 | 7 | 14 Apache ActiveMQ Classic 2022-03-09 5.17.x 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/completion/booleanoption.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | function _propose_files() { 5 | local cur=${COMP_WORDS[COMP_CWORD]} 6 | COMPREPLY=($(compgen -f "$cur")) 7 | } 8 | 9 | 10 | function _propose_flags() { 11 | local FLAGS="$@" 12 | local cur=${COMP_WORDS[COMP_CWORD]} 13 | 14 | # minus flags we've used 15 | for ((i = 0; i < ${#COMP_WORDS[*]} - 1; i++)); do 16 | n="${COMP_WORDS[$i]}" 17 | [[ "$n" == -* ]] && { 18 | n="${n/=*/=}" 19 | FLAGS=("${FLAGS[@]/$n/}") 20 | } 21 | done 22 | 23 | COMPREPLY=($(compgen -W "${FLAGS[*]}" -- "$cur")) 24 | } 25 | 26 | 27 | function _propose_flag_values() { 28 | local VALUES="$@" 29 | local cur=${COMP_WORDS[COMP_CWORD]} 30 | 31 | cur="$(echo "$cur" | perl -pe 's/[^=]+=//')" 32 | COMPREPLY=($(compgen -W "${VALUES[*]}" "$cur")) 33 | } 34 | 35 | 36 | function _propose_flag_file_values() { 37 | local cur=${COMP_WORDS[COMP_CWORD]} 38 | 39 | cur="$(echo "$cur" | perl -pe 's/[^=]+=//')" 40 | COMPREPLY=($(compgen -f "$cur")) 41 | } 42 | 43 | function _booleanoption() { 44 | local cur=${COMP_WORDS[COMP_CWORD]} 45 | local args_length=${#COMP_WORDS[@]} 46 | 47 | local COMMANDS=( 48 | help 49 | copy 50 | ) 51 | 52 | # List the commands 53 | [ $args_length -lt 3 ] && { 54 | COMPREPLY=($(compgen -W "${COMMANDS[*]}" "$cur")) 55 | return 56 | } 57 | 58 | # Command chosen. Delegate to its completion function 59 | 60 | # Verify the command is one we know and execute the 61 | # function that performs its completion 62 | local CMD=${COMP_WORDS[1]} 63 | for n in "${COMMANDS[@]}"; do 64 | [ "$CMD" = "$n" ] && { 65 | CMD="$(echo "$CMD" | perl -pe 's,[^a-zA-Z0-9],,g')" 66 | _booleanoption_$CMD 67 | return 68 | } 69 | done 70 | 71 | COMPREPLY=() 72 | } 73 | 74 | 75 | function _booleanoption_help() { 76 | _propose_files 77 | } 78 | 79 | function _booleanoption_copy() { 80 | local cur=${COMP_WORDS[COMP_CWORD]} 81 | 82 | case "$cur" in 83 | --force=*) _propose_flag_values "true" "false" ;; 84 | -*) _propose_flags "--force=";; 85 | *) _propose_files ;; 86 | esac 87 | 88 | } 89 | 90 | complete -F _booleanoption booleanoption 91 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/completion/foo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | function _propose_files() { 5 | local cur=${COMP_WORDS[COMP_CWORD]} 6 | COMPREPLY=($(compgen -f "$cur")) 7 | } 8 | 9 | 10 | function _propose_flags() { 11 | local FLAGS="$@" 12 | local cur=${COMP_WORDS[COMP_CWORD]} 13 | 14 | # minus flags we've used 15 | for ((i = 0; i < ${#COMP_WORDS[*]} - 1; i++)); do 16 | n="${COMP_WORDS[$i]}" 17 | [[ "$n" == -* ]] && { 18 | n="${n/=*/=}" 19 | FLAGS=("${FLAGS[@]/$n/}") 20 | } 21 | done 22 | 23 | COMPREPLY=($(compgen -W "${FLAGS[*]}" -- "$cur")) 24 | } 25 | 26 | 27 | function _propose_flag_values() { 28 | local VALUES="$@" 29 | local cur=${COMP_WORDS[COMP_CWORD]} 30 | 31 | cur="$(echo "$cur" | perl -pe 's/[^=]+=//')" 32 | COMPREPLY=($(compgen -W "${VALUES[*]}" "$cur")) 33 | } 34 | 35 | 36 | function _propose_flag_file_values() { 37 | local cur=${COMP_WORDS[COMP_CWORD]} 38 | 39 | cur="$(echo "$cur" | perl -pe 's/[^=]+=//')" 40 | COMPREPLY=($(compgen -f "$cur")) 41 | } 42 | 43 | function _foo() { 44 | local cur=${COMP_WORDS[COMP_CWORD]} 45 | local args_length=${#COMP_WORDS[@]} 46 | 47 | local COMMANDS=( 48 | red 49 | help 50 | green 51 | blue 52 | ) 53 | 54 | # List the commands 55 | [ $args_length -lt 3 ] && { 56 | COMPREPLY=($(compgen -W "${COMMANDS[*]}" "$cur")) 57 | return 58 | } 59 | 60 | # Command chosen. Delegate to its completion function 61 | 62 | # Verify the command is one we know and execute the 63 | # function that performs its completion 64 | local CMD=${COMP_WORDS[1]} 65 | for n in "${COMMANDS[@]}"; do 66 | [ "$CMD" = "$n" ] && { 67 | CMD="$(echo "$CMD" | perl -pe 's,[^a-zA-Z0-9],,g')" 68 | _foo_$CMD 69 | return 70 | } 71 | done 72 | 73 | COMPREPLY=() 74 | } 75 | 76 | 77 | function _foo_red() { 78 | _propose_files 79 | } 80 | 81 | function _foo_help() { 82 | _propose_files 83 | } 84 | 85 | function _foo_green() { 86 | _propose_files 87 | } 88 | 89 | function _foo_blue() { 90 | _propose_files 91 | } 92 | 93 | complete -F _foo foo 94 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/completion/overloaded.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | function _propose_files() { 5 | local cur=${COMP_WORDS[COMP_CWORD]} 6 | COMPREPLY=($(compgen -f "$cur")) 7 | } 8 | 9 | 10 | function _propose_flags() { 11 | local FLAGS="$@" 12 | local cur=${COMP_WORDS[COMP_CWORD]} 13 | 14 | # minus flags we've used 15 | for ((i = 0; i < ${#COMP_WORDS[*]} - 1; i++)); do 16 | n="${COMP_WORDS[$i]}" 17 | [[ "$n" == -* ]] && { 18 | n="${n/=*/=}" 19 | FLAGS=("${FLAGS[@]/$n/}") 20 | } 21 | done 22 | 23 | COMPREPLY=($(compgen -W "${FLAGS[*]}" -- "$cur")) 24 | } 25 | 26 | 27 | function _propose_flag_values() { 28 | local VALUES="$@" 29 | local cur=${COMP_WORDS[COMP_CWORD]} 30 | 31 | cur="$(echo "$cur" | perl -pe 's/[^=]+=//')" 32 | COMPREPLY=($(compgen -W "${VALUES[*]}" "$cur")) 33 | } 34 | 35 | 36 | function _propose_flag_file_values() { 37 | local cur=${COMP_WORDS[COMP_CWORD]} 38 | 39 | cur="$(echo "$cur" | perl -pe 's/[^=]+=//')" 40 | COMPREPLY=($(compgen -f "$cur")) 41 | } 42 | 43 | function _overloaded() { 44 | local cur=${COMP_WORDS[COMP_CWORD]} 45 | local args_length=${#COMP_WORDS[@]} 46 | 47 | local COMMANDS=( 48 | help 49 | push 50 | ) 51 | 52 | # List the commands 53 | [ $args_length -lt 3 ] && { 54 | COMPREPLY=($(compgen -W "${COMMANDS[*]}" "$cur")) 55 | return 56 | } 57 | 58 | # Command chosen. Delegate to its completion function 59 | 60 | # Verify the command is one we know and execute the 61 | # function that performs its completion 62 | local CMD=${COMP_WORDS[1]} 63 | for n in "${COMMANDS[@]}"; do 64 | [ "$CMD" = "$n" ] && { 65 | CMD="$(echo "$CMD" | perl -pe 's,[^a-zA-Z0-9],,g')" 66 | _overloaded_$CMD 67 | return 68 | } 69 | done 70 | 71 | COMPREPLY=() 72 | } 73 | 74 | 75 | function _overloaded_help() { 76 | _propose_files 77 | } 78 | 79 | function _overloaded_push() { 80 | local cur=${COMP_WORDS[COMP_CWORD]} 81 | 82 | case "$cur" in 83 | --verbose=*) _propose_flag_file_values ;; 84 | -u=*) _propose_flag_file_values ;; 85 | -*) _propose_flags "--verbose=" "-u=";; 86 | *) _propose_files ;; 87 | esac 88 | 89 | } 90 | 91 | complete -F _overloaded overloaded 92 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.AdvancedArrayArgTest$OneExtra_copy.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: copy [options] URI... URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.AdvancedArrayArgTest$RequiredList_copy.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: copy URI... URI 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.AdvancedArrayArgTest$TwoExtra_copy.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: copy [options] URI... URI URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean boolean... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte byte... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doChar.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doChar char... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble double... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat float... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt int... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong long... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort short... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString String... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgArraysTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI URI... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean Boolean... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte Byte... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doCharacter.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doCharacter Character... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble Double... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat Float... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt Integer... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong Long... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort Short... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString String... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ArgListsTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI URI... 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BeanValidationTest$Duplicates_check.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: check File 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BeanValidationTest$Duplicates_empty.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: empty String 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BooleanOptionsTest$Commands_object.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: object [options] 3 | 4 | Options: 5 | --no-action 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BooleanOptionsTest$Commands_object2.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: object2 [options] 3 | 4 | Options: 5 | --action 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BooleanOptionsTest$Commands_object3.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: object3 [options] 3 | 4 | Options: 5 | --action= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BooleanOptionsTest$Commands_primitive.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: primitive [options] 3 | 4 | Options: 5 | --no-action 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BooleanOptionsTest$Commands_primitive2.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: primitive2 [options] 3 | 4 | Options: 5 | --action 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.BooleanOptionsTest$Commands_primitive3.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: primitive3 [options] 3 | 4 | Options: 5 | --action 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_booleanOption.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: booleanOption [options] 3 | 4 | Options: 5 | --long 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_cat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: cat File 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_ls.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: ls [options] File 3 | 4 | Options: 5 | --long= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_prefixed.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: prefixed [options] 3 | 4 | Options: 5 | -value= 6 | ----value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_required.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: required [options] 3 | 4 | Options: 5 | --pass= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_set.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: set [options] 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_tail.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: tail [options] File int 3 | 4 | Options: 5 | --number= default: 100 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_tar.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: tar [options] 3 | 4 | Options: 5 | -x= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CmdMethodTest$Commands_touch.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: touch File 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Copy_copy.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: copy [options] File File 3 | 4 | Options: 5 | --force 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Foo_blue.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: blue 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Foo_green.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: green 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Foo_red.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: red 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Git_git.txt: -------------------------------------------------------------------------------- 1 | Usage: git [subcommand] [options] 2 | 3 | Sub commands: 4 | 5 | push 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Git_git_push.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: git push [options] 3 | 4 | Options: 5 | --verbose, -v= 6 | -u= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Svn_svn.txt: -------------------------------------------------------------------------------- 1 | Usage: svn [subcommand] [options] 2 | 3 | Sub commands: 4 | 5 | checkout 6 | commit 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Svn_svn_checkout.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: svn checkout [options] URI 3 | 4 | Options: 5 | --username= 6 | --password= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.CompleterTest$Svn_svn_commit.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: svn commit [options] String... 3 | 4 | Options: 5 | --username= 6 | --password= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onComma.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: onComma [options] 3 | 4 | Options: 5 | --value= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onTab.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: onTab [options] 3 | 4 | Options: 5 | --value= default: 2,3, 5,7, 11,13 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onUnicode.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: onUnicode [options] 3 | 4 | Options: 5 | --value= default: 2,3 5,7 11,13, 17 19,23, 29 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultListOptionSplittingTest$Commands_onlyBeforeSubstition.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: onlyBeforeSubstition [options] 3 | 4 | Options: 5 | --value= default: ${value1}, ${value2} 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] Color 3 | 4 | Options: 5 | --foo= default: false, true, false 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doCharacter.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doCharacter [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsAndOptionsTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI [options] Color 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | --color= enum: red, green, blue, orange 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] 3 | 4 | Options: 5 | --foo= default: false, true, false 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doCharacter.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doCharacter [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionListsTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI [options] 3 | 4 | Options: 5 | --foo= default: 2, 3, 5 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] boolean boolean 3 | 4 | Options: 5 | --p1 6 | --p2 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] byte byte 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doChar.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doChar [options] char char 3 | 4 | Options: 5 | --p1= default: 6 | --p2= default: 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] double double 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] float float 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] int int 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] long long 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doMixed.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doMixed [options] URI String 3 | 4 | Options: 5 | --p1= 6 | --p2= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] short short 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString [options] String String 3 | 4 | Options: 5 | --p1= 6 | --p2= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultOptionsAndSuppliedArgsTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI [options] URI URI 3 | 4 | Options: 5 | --p1= 6 | --p2= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultSubstitutionTest$Commands_doAllExplicit.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doAllExplicit [options] Value Value... 3 | 4 | Options: 5 | --user-home= default: ${user.home} 6 | --directory= default: ${user.home}, ${user.dir} 7 | --format= 8 | --pattern= 9 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.DefaultSubstitutionTest$Commands_doRelyOnDefaults.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doRelyOnDefaults [options] Value Value... 3 | 4 | Options: 5 | --user-home= default: ${user.home} 6 | --directory= default: ${user.home}, ${user.dir} 7 | --format= 8 | --pattern= 9 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.EnumOptionListTest$Commands_array.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: array [options] 3 | 4 | Options: 5 | --action= default: WALK 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.EnumOptionListTest$Commands_list.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: list [options] 3 | 4 | Options: 5 | --action= default: WALK 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doAll.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doAll [options] 3 | 4 | Options: 5 | --byte= default: 42 6 | --char= default: D 7 | --no-boolean 8 | --short= default: 1024 9 | --int= default: 3301976 10 | --long= default: 10000000000 11 | --float= default: 10.0 12 | --double= default: 20.0 13 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] 3 | 4 | Options: 5 | --no-value 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] 3 | 4 | Options: 5 | --value= default: 42 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doChar.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doChar [options] 3 | 4 | Options: 5 | --value= default: D 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] 3 | 4 | Options: 5 | --value= default: 20.0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] 3 | 4 | Options: 5 | --value= default: 10.0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] 3 | 4 | Options: 5 | --value= default: 3301976 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] 3 | 4 | Options: 5 | --value= default: 10000000000 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ExplicitPrimitiveOptionDefaultsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] 3 | 4 | Options: 5 | --value= default: 1024 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpTest$DefaultsAndEnums_test.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: test [options] URI URI 3 | 4 | Options: 5 | -r, --recursive recurse into directories 6 | --links, -l copy symlinks as symlinks 7 | -p, --perms preserve permissions 8 | --owner= preserve owner (super-user only) 9 | (default: ${user.name}) 10 | --group preserve group 11 | --devices preserve device files (super-user only) 12 | --specials preserve special files 13 | --times preserve times 14 | -x 15 | --exclude, -e= exclude files matching PATTERN 16 | --exclude-from= read exclude patterns from FILE 17 | --include= don't exclude files matching PATTERN 18 | (default: .*) 19 | --include-from= read include patterns from FILE 20 | --highlight= default: orange 21 | (enum: red, green, blue, orange) 22 | --foreground= color to use in the foreground 23 | (default: orange) 24 | (enum: red, green, blue, orange) 25 | --background, --bg= color to use in the background 26 | (enum: red, green, blue, orange) 27 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpTest$Git_git.txt: -------------------------------------------------------------------------------- 1 | Usage: git [subcommand] [options] 2 | 3 | Sub commands: 4 | 5 | pull 6 | push 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpTest$Git_git_pull.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: git pull [options] String 3 | 4 | Options: 5 | --verbose 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpTest$Git_git_push.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: git push [options] String 3 | 4 | Options: 5 | --verbose Output debug information 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpTest$OptionLists_test.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: test [options] URI URI 3 | 4 | Options: 5 | --recursive= recurse into directories 6 | --links= copy symlinks as symlinks 7 | --perms preserve permissions 8 | --owner= preserve owner (super-user only) 9 | (default: ${user.name}) 10 | --group preserve group 11 | --devices preserve device files (super-user only) 12 | --specials preserve special files 13 | --times preserve times 14 | --exclude= exclude files matching PATTERN 15 | --exclude-from= read exclude patterns from FILE 16 | --include= don't exclude files matching PATTERN 17 | (default: .*) 18 | --include-from= read include patterns from FILE 19 | --highlight= default: orange, red 20 | --foreground= color to use in the foreground 21 | (default: orange) 22 | --background= color to use in the background 23 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpTest$Rsync_rsync.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: orange rsync [options] URI... URI 3 | 4 | Options: 5 | --recursive recurse into directories 6 | --links copy symlinks as symlinks 7 | --perms preserve permissions 8 | --owner preserve owner (super-user only) 9 | --group preserve group 10 | --devices preserve device files (super-user only) 11 | --specials preserve special files 12 | --times preserve times 13 | --exclude= exclude files matching PATTERN 14 | --exclude-from= read exclude patterns from FILE 15 | --include= don't exclude files matching PATTERN 16 | --include-from= read include patterns from FILE 17 | --no-progress, --no-p don't show progress during transfer 18 | 19 | orange 0.12 20 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpWithInnerOptionsTest$DefaultsAndEnums_test.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: test [options] URI URI 3 | 4 | Options: 5 | --recursive recurse into directories 6 | --links copy symlinks as symlinks 7 | --perms preserve permissions 8 | --owner= preserve owner (super-user only) 9 | (default: ${user.name}) 10 | --group preserve group 11 | --devices preserve device files (super-user only) 12 | --specials preserve special files 13 | --times preserve times 14 | --exclude= exclude files matching PATTERN 15 | --exclude-from= read exclude patterns from FILE 16 | --include= don't exclude files matching PATTERN 17 | --include-from= read include patterns from FILE 18 | --highlight= default: orange 19 | (enum: red, green, blue, orange) 20 | --foreground= color to use in the foreground 21 | (default: orange) 22 | (enum: red, green, blue, orange) 23 | --background= color to use in the background 24 | (enum: red, green, blue, orange) 25 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpWithInnerOptionsTest$OptionLists_test.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: test [options] URI URI 3 | 4 | Options: 5 | --recursive= recurse into directories 6 | --links= copy symlinks as symlinks 7 | --perms preserve permissions 8 | --owner= preserve owner (super-user only) 9 | (default: ${user.name}) 10 | --group preserve group 11 | --devices preserve device files (super-user only) 12 | --specials preserve special files 13 | --times preserve times 14 | --exclude= exclude files matching PATTERN 15 | --exclude-from= read exclude patterns from FILE 16 | --include= don't exclude files matching PATTERN 17 | --include-from= read include patterns from FILE 18 | --highlight= default: orange, red 19 | --foreground= color to use in the foreground 20 | (default: orange) 21 | --background= color to use in the background 22 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.HelpWithInnerOptionsTest$Rsync_rsync.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: rsync [options] URI... URI 3 | 4 | Options: 5 | --recursive recurse into directories 6 | --links copy symlinks as symlinks 7 | --perms preserve permissions 8 | --owner preserve owner (super-user only) 9 | --group preserve group 10 | --devices preserve device files (super-user only) 11 | --specials preserve special files 12 | --times preserve times 13 | --exclude= exclude files matching PATTERN 14 | --exclude-from= read exclude patterns from FILE 15 | --include= don't exclude files matching PATTERN 16 | --include-from= read include patterns from FILE 17 | --no-progress don't show progress during transfer 18 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doAll.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doAll [options] 3 | 4 | Options: 5 | --byte= default: 0 6 | --char= default: 7 | --boolean 8 | --short= default: 0 9 | --int= default: 0 10 | --long= default: 0 11 | --float= default: 0 12 | --double= default: 0 13 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] 3 | 4 | Options: 5 | --value 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] 3 | 4 | Options: 5 | --value= default: 0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doChar.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doChar [options] 3 | 4 | Options: 5 | --value= default: 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] 3 | 4 | Options: 5 | --value= default: 0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] 3 | 4 | Options: 5 | --value= default: 0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] 3 | 4 | Options: 5 | --value= default: 0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] 3 | 4 | Options: 5 | --value= default: 0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ImplicitPrimitiveOptionDefaultsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] 3 | 4 | Options: 5 | --value= default: 0 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.MainTest$Foo_blue.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: blue 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.MainTest$Foo_green.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: green 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.MainTest$Foo_red.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: red 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ManyOptionTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString [options] 3 | 4 | Options: 5 | --foo, --foox, -f= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.ManyOptionTest$Commands_rsync.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: rsync [options] 3 | 4 | Options: 5 | -d, --dirs= 6 | -l, --links= 7 | -e, --rsh= 8 | --del, --delete-during= 9 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doChar.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doChar [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionArraysTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doCharacter.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doCharacter [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionListsTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI [options] 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_args.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: args [options] String URI 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: complex [options] URI... URI URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex2.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: complex2 [options] URI... URI URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex3.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: complex3 [options] URI... URI URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex4.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: complex4 [options] URI... URI URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_complex5.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: complex5 [options] URI... URI URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_mixed.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: mixed [options] String URI Shape URI 3 | 4 | Options: 5 | --size= default: 0 6 | --key= 7 | --value= 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_options.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: options [options] 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_optionsAndArgs.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: optionsAndArgs [options] String URI 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_simple.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: simple [options] URI... URI URI 3 | 4 | Options: 5 | --foo= 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectAdvancedArrayArgTest$Commands_twoBeans.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: twoBeans String URI 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectTest$Commands_args.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: args [options] String URI 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectTest$Commands_mixed.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: mixed [options] String URI Shape URI 3 | 4 | Options: 5 | --size= default: 0 6 | --key= 7 | --value= 8 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectTest$Commands_options.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: options [options] 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectTest$Commands_optionsAndArgs.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: optionsAndArgs [options] String URI 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectTest$Commands_twoBeans.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: twoBeans String URI 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OptionsObjectValidationTest$Commands_validation.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: validation [options] String URI 3 | 4 | Options: 5 | --key= 6 | --value= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.OverloadedCmdMethodTest$TestCommands_help.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: help [options1] 3 | help [options2] String 4 | help [options3] String String 5 | 6 | Options1: 7 | --level= default: 0 8 | 9 | Options2: 10 | --lang= 11 | 12 | Options3: 13 | --lang= 14 | --colors 15 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.PluggableDefaultParsingTest$Orange_defaults.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: defaults [options] 3 | 4 | Options: 5 | --user= default: ${user.name} 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.PluggableDefaultParsingTest$Orange_property.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: property String 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doBoolean.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doBoolean [options] boolean boolean 3 | 4 | Options: 5 | --p1 6 | --p2 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doByte.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doByte [options] byte byte 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doChar.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doChar [options] char char 3 | 4 | Options: 5 | --p1= default: 6 | --p2= default: 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doDouble.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doDouble [options] double double 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doFloat.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doFloat [options] float float 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doInt.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doInt [options] int int 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doLong.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doLong [options] long long 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doMixed.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doMixed [options] URI String 3 | 4 | Options: 5 | --p1= 6 | --p2= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doShort.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doShort [options] short short 3 | 4 | Options: 5 | --p1= default: 0 6 | --p2= default: 0 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doString.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doString [options] String String 3 | 4 | Options: 5 | --p1= 6 | --p2= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SomeOptionsAndSuppliedArgsTest$Commands_doURI.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: doURI [options] URI URI 3 | 4 | Options: 5 | --p1= 6 | --p2= 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SubCommandsTest$Git_git.txt: -------------------------------------------------------------------------------- 1 | Usage: git [subcommand] [options] 2 | 3 | Sub commands: 4 | 5 | pull 6 | push 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SubCommandsTest$Git_git_pull.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: git pull [options] String 3 | 4 | Options: 5 | --verbose 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SubCommandsTest$Git_git_push.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: git push [options] String 3 | 4 | Options: 5 | --verbose 6 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SystemPropertiesTest$Orange_defaults.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: defaults [options] 3 | 4 | Options: 5 | --user= default: ${user.name} 6 | --home= default: ${user.dir} 7 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/help/org.tomitribe.crest.SystemPropertiesTest$Orange_property.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage: property String 3 | 4 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/man/input-markdown.txt: -------------------------------------------------------------------------------- 1 | # General 2 | 3 | 4 | Rsync copies files either to or from a remote host, or locally on the current 5 | host (it does not support copying files between two remote hosts). 6 | 7 | There are two different ways for rsync to contact a remote system: using a 8 | remote-shell program as the transport (such as ssh or rsh) or contacting an rsync 9 | daemon directly via TCP. The remote-shell transport is used whenever the source or 10 | destination path contains a single colon (:) separator after a host specification. 11 | Contacting an rsync daemon directly happens when the source or destination 12 | path contains a double colon (::) separator after a host specification, OR when 13 | an rsync:// URL is specified (see also the "USING RSYNC-DAEMON FEATURES VIA A REMOTE-SHELL 14 | CONNECTION" section for an exception to this latter rule). 15 | 16 | As a special case, if a single source arg is specified without a 17 | destination, the files are listed in an output format similar to "ls -l". 18 | 19 | As expected, if neither the source or destination path specify a remote 20 | host, the copy occurs locally (see also the --list-only option). 21 | 22 | # Setup 23 | 24 | See the file README for installation instructions. 25 | 26 | Once installed, you can use rsync to any machine that you can access via a remote shell (as well as 27 | some that you can access using the rsync daemon-mode protocol). For remote transfers, 28 | a modern rsync uses ssh for its communications, but it may have been configured to 29 | use a different remote shell by default, such as rsh or remsh. 30 | 31 | 32 | You can also specify any remote shell you like, either by using the -e command 33 | line option, or by setting the RSYNC_RSH environment variable. 34 | 35 | Note that rsync must be installed on both the source and destination machines. 36 | 37 | # usage 38 | 39 | You use rsync in the same way you use rcp. You must specify a source and a destination, one of which may be remote. 40 | 41 | Perhaps the best way to explain the syntax is with some examples: 42 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/org/tomitribe/crest/OptionDescriptions.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | a = uno 19 | b = dos 20 | 21 | r recurse into directories 22 | p preserve permissions 23 | recursive recurse into directories 24 | links copy symlinks as symlinks 25 | perms preserve permissions 26 | owner preserve owner (super-user only) 27 | group preserve group 28 | times preserve times 29 | devices preserve device files (super-user only) 30 | specials preserve special files 31 | exclude exclude files matching PATTERN 32 | exclude-from read exclude patterns from FILE 33 | include don't exclude files matching PATTERN 34 | include-from read include patterns from FILE 35 | progress show progress during transfer 36 | rsync.progress don't show progress during transfer 37 | foreground color to use in the foreground 38 | background color to use in the background 39 | -------------------------------------------------------------------------------- /tomitribe-crest/src/test/resources/org/tomitribe/crest/OptionDescriptions_en.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | a = one 19 | c = three 20 | -------------------------------------------------------------------------------- /toolz/src/main/resources/META-INF/NOTICE: -------------------------------------------------------------------------------- 1 | toolz 2 | Copyright 2014 Tomitribe Corporation 3 | 4 | This product includes software developed at 5 | Tomitribe Corporation (http://www.tomitribe.com/). 6 | 7 | This product includes software developed at 8 | The Apache Software Foundation (http://www.apache.org/). 9 | 10 | The following copyright notice(s) were affixed to portions of this code 11 | with which this file is now or was at one time distributed. 12 | 13 | This product includes software developed by agimatec GmbH. 14 | Copyright 2007-2010 Agimatec GmbH. All rights reserved. 15 | 16 | This product includes software from the Spring Framework, 17 | under the Apache License 2.0 (see: StringUtils.containsWhitespace()) 18 | -------------------------------------------------------------------------------- /toolz/src/main/resources/org/example/toolz/OptionDescriptions.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | recursive recurse into directories 19 | links copy symlinks as symlinks 20 | perms preserve permissions 21 | owner preserve owner (super-user only) 22 | group preserve group 23 | times preserve times 24 | devices preserve device files (super-user only) 25 | specials preserve special files 26 | exclude exclude files matching PATTERN 27 | exclude-from read exclude patterns from FILE 28 | include don't exclude files matching PATTERN 29 | include-from read include patterns from FILE 30 | # Note the .