Skip to content

Commit

Permalink
Second cut of adding support for argument groups:
Browse files Browse the repository at this point in the history
* mutually exclusive options (#199)
* option that must co-occur (#295)
* option grouping in the usage help message (#450)
* repeating composite arguments (#358 and #635) (this should also cover the use cases presented in #454 and #434 requests for repeatable subcommands)
  • Loading branch information
remkop committed Mar 18, 2019
1 parent 3337db2 commit 27ab555
Show file tree
Hide file tree
Showing 19 changed files with 2,066 additions and 1,321 deletions.
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ buildscript {

dependencies {
classpath "org.asciidoctor:asciidoctor-gradle-plugin:$asciidoctorGradlePluginVersion"
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.15'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradleBintrayPluginVersion"
}
}

apply plugin: 'org.asciidoctor.convert'
apply plugin: 'org.asciidoctor.convert' // version '1.5.8.1'
apply plugin: 'distribution'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
Expand Down Expand Up @@ -158,10 +159,18 @@ jar {

javadoc.options.overview = "src/main/java/overview.html"
javadoc.dependsOn('asciidoctor')
asciidoctorj {
version = '1.5.5'
}
asciidoctor {
sourceDir = file('docs')
outputDir = file('build/docs')
logDocuments = true
// backends 'pdf', 'html'
// attributes 'sourcedir': file('docs') //project.sourceSets.main.java.srcDirs[0]
//// attributes 'pdf-stylesdir': 'theme',
//// 'pdf-style': 'custom',
//// 'sourcedir': file('docs') //project.sourceSets.main.java.srcDirs[0]
}
// jacoco 0.8.2 does not work with Java 13; gradle 4.x has no JavaVersion enum value for Java 12
if (org.gradle.api.JavaVersion.current().isJava11Compatible()) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.98
minimum = 0.97
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions picocli-codegen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ plugins {
group 'info.picocli'
description 'Picocli Code Generation - Tools to generate documentation, configuration, source code and other files from a picocli model.'
version "$projectVersion"
sourceCompatibility = 1.6
targetCompatibility = 1.6

dependencies {
compile rootProject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package picocli.codegen.annotation.processing;

import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.IFactory;
import picocli.CommandLine.Mixin;
Expand Down Expand Up @@ -942,6 +943,7 @@ static boolean isAnnotated(Element e) {
return false
|| e.getAnnotation(Option.class) == null
|| e.getAnnotation(Parameters.class) == null
|| e.getAnnotation(ArgGroup.class) == null
|| e.getAnnotation(Unmatched.class) == null
|| e.getAnnotation(Mixin.class) == null
|| e.getAnnotation(Spec.class) == null
Expand Down Expand Up @@ -995,6 +997,7 @@ private TypedMember(ExecutableElement method) {
public boolean isArgSpec() { return isOption() || isParameter() || isMethodParameter(); }
public boolean isOption() { return isAnnotationPresent(Option.class); }
public boolean isParameter() { return isAnnotationPresent(Parameters.class); }
public boolean isArgGroup() { return isAnnotationPresent(ArgGroup.class); }
public boolean isMixin() { return isAnnotationPresent(Mixin.class); }
public boolean isUnmatched() { return isAnnotationPresent(Unmatched.class); }
public boolean isInjectSpec() { return isAnnotationPresent(Spec.class); }
Expand All @@ -1011,6 +1014,12 @@ public String getToString() {
public boolean hasInitialValue() { return hasInitialValue; }
public boolean isMethodParameter() { return position >= 0; }
public int getMethodParamPosition() { return position; }

@Override
public CommandLine.Model.IScope scope() {
return null; // FIXME
}

public String getMixinName() {
String annotationName = getAnnotation(Mixin.class).name();
return empty(annotationName) ? getName() : annotationName;
Expand Down
11 changes: 11 additions & 0 deletions picocli-codegen/src/test/resources/example-reflect.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,17 @@
{ "name" : "helpRequested" }
]
},
{
"name" : "picocli.CommandLine$Model$ObjectScope",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"methods" : [
{ "name" : "setMinimum", "parameterTypes" : ["int"] },
{ "name" : "setOtherFiles", "parameterTypes" : ["java.util.List"] }
]
},
{
"name" : "picocli.codegen.aot.graalvm.Example",
"allDeclaredConstructors" : true,
Expand Down
7 changes: 7 additions & 0 deletions picocli-codegen/src/test/resources/issue622-reflect.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@
{ "name" : "out" }
]
},
{
"name" : "picocli.CommandLine$Model$ObjectScope",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "picocli.codegen.aot.graalvm.Issue622AbstractCommand",
"allDeclaredConstructors" : true,
Expand Down

0 comments on commit 27ab555

Please sign in to comment.