Skip to content

Commit

Permalink
[#299][#459] update sample "generate man pages" Gradle project
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Feb 10, 2020
1 parent 34a7d3a commit b15256c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath "org.asciidoctor:asciidoctor-gradle-plugin:$asciidoctorGradlePluginVersion"
classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.6.1"
}
}

Expand All @@ -33,19 +33,21 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
dependencies {
compile "info.picocli:picocli:4.2.0"
annotationProcessor "info.picocli:picocli-codegen:4.2.0"
compile "info.picocli:picocli:4.2.0-SNAPSHOT"
annotationProcessor "info.picocli:picocli-codegen:4.2.0-SNAPSHOT"
}

mainClassName = "my.pkg.MyCommand"
project.ext {
mainClassName = "com.company.Main"
}

task generateManpageAsciiDoc(type: JavaExec) {
dependsOn(classes)
group = "Documentation"
description = "Generate AsciiDoc manpage"
classpath(configurations.compile, configurations.annotationProcessor, sourceSets.main.runtimeClasspath)
main 'picocli.codegen.docgen.manpage.ManPageGenerator'
args mainClassName, "--outdir=${project.buildDir}/generated/docs", "-v" //, "--template-dir=src/docs/mantemplates"
args project.ext.mainClassName, "--outdir=${project.buildDir}/generated/docs", "-v", "--template-dir=src/docs/mantemplates"
}

apply plugin: 'org.asciidoctor.convert'
Expand All @@ -54,5 +56,6 @@ asciidoctor {
sourceDir = file("${project.buildDir}/generated/docs")
outputDir = file("${project.buildDir}/docs")
logDocuments = true
backends 'manpage'
backends 'manpage', 'html5'
}
assemble.dependsOn(asciidoctor)
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,63 @@

import java.util.concurrent.Callable;

@Command(name = "top", mixinStandardHelpOptions = true,
version = {"test 1.0", "picocli " + CommandLine.VERSION})
@Command(name = "top", mixinStandardHelpOptions = true, showAtFileInUsageHelp = true,
version = {"test 1.0", "picocli " + CommandLine.VERSION},
header = "display Linux processes",
description = {
"The @|bold top|@ program provides a dynamic real-time view of a running " +
"system. It can display system summary information as well as a list " +
"of @|bold processes|@ or @|bold threads|@ currently being managed by the Linux kernel. " +
"The types of system summary information shown and the types, order " +
"and size of information displayed for processes are all user " +
"configurable and that configuration can be made persistent across " +
"restarts.",
"",
"The program provides a limited interactive interface for process " +
"manipulation as well as a much more extensive interface for personal " +
"configuration -- encompassing every aspect of its operation. And " +
"while @|bold top|@ is referred to throughout this document, you are free to " +
"name the program anything you wish. That new name, possibly an " +
"alias, will then be reflected on top's display and used when reading " +
"and writing a configuration file."},
optionListHeading = "COMMAND-LINE Options%n"
)
public class Main implements Callable<Integer> {

@Option(names = "-x") int x;
@Option(names = "-y") int y;
@Option(names = "-z") int z;
@Option(names = "-b", description = {"Batch-mode operation.",
"Starts top in Batch mode, which could be useful for sending " +
"output from top to other programs or to a file. In this mode, " +
"top will not accept input and runs until the iterations limit " +
"you've set with the `-n` command-line option or until killed."})
boolean batchMode;

@Option(names = "-c", description = {"Command-line/Program-name toggle.",
"Starts top with the last remembered `c` state reversed. Thus, " +
"if top was displaying command lines, now that field will show " +
"program names, and vice versa. See the `c` interactive command " +
"for additional information."})
boolean commandMode;

@Option(names = "-d", description = {"Delay-time interval as: `-d ss.t` (secs.tenths)",
"Specifies the delay between screen updates, and overrides the " +
"corresponding value in one's personal configuration file or the " +
"startup default. Later this can be changed with the `d` or `s` " +
"interactive commands.",
"",
"Fractional seconds are honored, but a negative number is not allowed."})
String delayTime;

@Option(names = "-H", description = {"Threads-mode operation.",
"Instructs top to display individual threads. Without this " +
"command-line option a summation of all threads in each process " +
"is shown. Later this can be changed with the `H` interactive command."})
boolean threadsMode;

@Option(names = "-n", description = {"Number-of-iterations limit as: `-n number`",
"Specifies the maximum number of iterations, or frames, top " +
"should produce before ending."})
int number;


public static void main(String[] args) {
System.exit(new CommandLine(new Main()).execute(args));
Expand Down

0 comments on commit b15256c

Please sign in to comment.