Skip to content

Commit 50b30fd

Browse files
committed
[#1173] DOC: Further improve user manual and Quick Guide
1 parent e11712b commit 50b30fd

File tree

5 files changed

+281
-94
lines changed

5 files changed

+281
-94
lines changed

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Picocli follows [semantic versioning](http://semver.org/).
2929
* [#1168][#1169] DOC: Ensure `org.jline.terminal.Terminal` is closed when done. Thanks to [David Walluck](https://github.com/dwalluck) for the pull request.
3030
* [#1167] DOC: Fix broken links in Quick Guide. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
3131
* [#1171] DOC: Various documentation improvements. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
32+
* [#1173] DOC: Improve example applications for the user manual and Quick Guide. Thanks to [Andreas Deininger](https://github.com/deining) for the pull request.
3233
* [#1170] TEST: Ensure ANSI is disabled in `ManPageGeneratorTest` regardless of environment. Thanks to [David Walluck](https://github.com/dwalluck) for the pull request.
3334
* [#1166][#1103] TEST: Ensure ANSI is disabled in `TracerTest` regardless of environment. Thanks to [David Walluck](https://github.com/dwalluck) for the pull request.
3435

docs/index.adoc

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,20 @@ Picocli-based applications can be ahead-of-time compiled to a image:https://www.
4747

4848
Picocli <<Generate Man Page Documentation,generates beautiful documentation>> for your application (HTML, PDF and Unix man pages).
4949

50-
Another distinguishing feature of picocli is how it aims
51-
to let users run picocli-based applications without requiring picocli as an external dependency:
50+
.An example usage help message with ANSI colors and styles
51+
image:checksum-usage-help.png[Screenshot of usage help with Ansi codes enabled]
52+
53+
Another distinguishing feature of picocli is how it aims to let users run picocli-based applications without requiring picocli as an external dependency:
5254
all the source code lives in a single file, to encourage application authors to include it _in source form_.
5355

54-
This is how it works: you annotate your class and picocli initializes it from the command line arguments, converting the input to strongly typed values in the fields of your class. If your class implements `Runnable` or `Callable`, you can let picocli kick off your application after parsing is successfully completed.
56+
How it works: annotate your class and picocli initializes it from the command line arguments, converting the input to strongly typed values in the fields of your class.
5557

56-
=== Sample application
57-
Let's get started by looking at minimal picocli-based command line application. This fully working sample app may be used to calculate the checksum(s) of one or more file(s) given as command line parameter(s):
58+
TIP: Picocli also provides a <<Programmatic API,programmatic API>>, separately from the annotations API.
5859

59-
.Synopsis of sample application
60-
image:checksum-usage-help.png[Screenshot of usage help with Ansi codes enabled]
60+
=== Example application
61+
The example below shows a short but fully functional picocli-based `checksum` command line application:
6162

62-
.Source code of sample application
63+
.A full working example picocli-based command line application
6364
[[CheckSum-application]]
6465
[source,java]
6566
----
@@ -79,7 +80,7 @@ import java.util.concurrent.Callable;
7980
class CheckSum implements Callable<Integer> {
8081
8182
@Parameters(index = "0", description = "The file whose checksum to calculate.")
82-
private File file; // <4>
83+
private File file;
8384
8485
@Option(names = {"-a", "--algorithm"}, description = "MD5, SHA-1, SHA-256, ...")
8586
private String algorithm = "MD5";
@@ -101,13 +102,11 @@ class CheckSum implements Callable<Integer> {
101102
}
102103
----
103104

104-
Create a class that represents your command and annotate this class with `@Command`. Let this class implement `Runnable` or `Callable` and your command can be <<Executing Commands,executed>> in one line of code. Annotate the fields of the command class with `@Option` or `@Parameters` to declare the options and positional parameters of your application. Use the `CommandLine.execute` method to parse the command line, handle errors, handle requests for usage and version help, and invoke the business logic. Eventually, your application may call `System.exit` with the returned exit code to signal success or failure to their caller.
105-
106-
The <<Mixin Standard Help Options,mixinStandardHelpOptions>> attribute adds --help and --version options to your application.
105+
Implement `Runnable` or `Callable` and your command can be <<Executing Commands,executed>> in one line of code. The example `main` method calls `CommandLine.execute` to parse the command line, handle errors, handle requests for usage and version help, and invoke the business logic. Applications can call `System.exit` with the returned exit code to signal success or failure to their caller.
107106

108-
TIP: Picocli also provides a <<Programmatic API,programmatic API>>, separately from the annotations API.
107+
The <<Mixin Standard Help Options,mixinStandardHelpOptions>> attribute adds `--help` and `--version` options to your application.
109108

110-
== Setting up your picocli based project
109+
== Getting Started
111110
You can add picocli as an external dependency to your project, or you can include it as source.
112111

113112
=== Add as External Dependency
@@ -6845,7 +6844,7 @@ The generated AsciiDoc files can be converted to HTML, PDF and unix man pages wi
68456844

68466845
See the link:https://github.com/remkop/picocli/tree/master/picocli-codegen#generate-documentation[Generate Documentation] section of the link:https://github.com/remkop/picocli/tree/master/picocli-codegen[picocli-codegen README] for details on how to generate and customize this documentation.
68476846

6848-
The man pages for the picocli built-in tools were created with this tool:
6847+
To see some examples, the man pages for the picocli built-in tools were created with this tool:
68496848

68506849
* link:man/gen-manpage.html[gen-manpage] (`picocli.codegen.docgen.manpage.ManPageGenerator`)
68516850
* link:man/picocli.AutoComplete.html[picocli.AutoComplete] (`picocli.AutoComplete`)

docs/index.html

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,12 @@ <h1>picocli - a mighty tiny command line interface</h1>
532532
<div id="toc" class="toc2">
533533
<div id="toctitle">Features</div>
534534
<ul class="sectlevel1">
535-
<li><a href="#_introduction">1. Introduction</a></li>
535+
<li><a href="#_introduction">1. Introduction</a>
536+
<ul class="sectlevel2">
537+
<li><a href="#_overview">1.1. Overview</a></li>
538+
<li><a href="#_example_application">1.2. Example application</a></li>
539+
</ul>
540+
</li>
536541
<li><a href="#_getting_started">2. Getting Started</a>
537542
<ul class="sectlevel2">
538543
<li><a href="#_add_as_external_dependency">2.1. Add as External Dependency</a></li>
@@ -854,30 +859,30 @@ <h1>picocli - a mighty tiny command line interface</h1>
854859
<h2 id="_introduction"><a class="anchor" href="#_introduction"></a>1. Introduction</h2>
855860
<div class="sectionbody">
856861
<div class="paragraph">
857-
<p>Picocli aims to be the easiest way to create rich command line applications that can run on and off the JVM.</p>
862+
<p>Picocli is a one-file framework for creating Java command line applications with almost zero code.
863+
Picocli aims to be the easiest way to create rich command line applications that can run on and off the JVM.</p>
858864
</div>
865+
<div class="sect2">
866+
<h3 id="_overview"><a class="anchor" href="#_overview"></a>1.1. Overview</h3>
859867
<div class="paragraph">
860-
<p>Picocli is a one-file framework for creating Java command line applications with almost zero code.
861-
Supports a variety of command line syntax styles including POSIX, GNU, MS-DOS and more.
862-
Generates highly customizable usage help messages with <a href="#_ansi_colors_and_styles">ANSI colors and styles</a>.
868+
<p>Picocli supports a variety of command line syntax styles including POSIX, GNU, MS-DOS and more and generates highly customizable usage help messages with <a href="#_ansi_colors_and_styles">ANSI colors and styles</a>.
863869
Picocli-based applications can have <a href="autocomplete.html">command line TAB completion</a> showing available options, option parameters and subcommands, for any level of nested subcommands.
864870
Picocli-based applications can be ahead-of-time compiled to a <span class="image"><img src="https://www.graalvm.org/resources/img/logo-colored.svg" alt="GraalVM"></span>
865871
<a href="#_graalvm_native_image">native image</a>, with extremely fast startup time and lower memory requirements, which can be distributed as a single executable file.</p>
866872
</div>
867873
<div class="paragraph">
868-
<p><span class="image"><img src="images/checksum-usage-help.png" alt="Screenshot of usage help with Ansi codes enabled"></span></p>
874+
<p>Picocli <a href="#_generate_man_page_documentation">generates beautiful documentation</a> for your application (HTML, PDF and Unix man pages).</p>
869875
</div>
870876
<div class="paragraph">
871-
<p>Picocli <a href="#_generate_man_page_documentation">generates beautiful documentation</a> for your application (HTML, PDF and Unix man pages).</p>
877+
<div class="title">An example usage help message with ANSI colors and styles</div>
878+
<p><span class="image"><img src="images/checksum-usage-help.png" alt="Screenshot of usage help with Ansi codes enabled"></span></p>
872879
</div>
873880
<div class="paragraph">
874-
<p>Another distinguishing feature of picocli is how it aims
875-
to let users run picocli-based applications without requiring picocli as an external dependency:
881+
<p>Another distinguishing feature of picocli is how it aims to let users run picocli-based applications without requiring picocli as an external dependency:
876882
all the source code lives in a single file, to encourage application authors to include it <em>in source form</em>.</p>
877883
</div>
878884
<div class="paragraph">
879-
<p>How it works: annotate your class and picocli initializes it from the command line arguments,
880-
converting the input to strongly typed values in the fields of your class.</p>
885+
<p>How it works: annotate your class and picocli initializes it from the command line arguments, converting the input to strongly typed values in the fields of your class.</p>
881886
</div>
882887
<div class="admonitionblock tip">
883888
<table>
@@ -891,6 +896,12 @@ <h2 id="_introduction"><a class="anchor" href="#_introduction"></a>1. Introducti
891896
</tr>
892897
</table>
893898
</div>
899+
</div>
900+
<div class="sect2">
901+
<h3 id="_example_application"><a class="anchor" href="#_example_application"></a>1.2. Example application</h3>
902+
<div class="paragraph">
903+
<p>The example below shows a short but fully functional picocli-based <code>checksum</code> command line application:</p>
904+
</div>
894905
<div id="CheckSum-application" class="listingblock">
895906
<div class="title">A full working example picocli-based command line application</div>
896907
<div class="content">
@@ -933,16 +944,14 @@ <h2 id="_introduction"><a class="anchor" href="#_introduction"></a>1. Introducti
933944
</div>
934945
</div>
935946
<div class="paragraph">
936-
<p>Implement <code>Runnable</code> or <code>Callable</code>, and your command can be <a href="#execute">executed</a> in one line of code.
937-
The example above uses the <code>CommandLine.execute</code> method
938-
to parse the command line, handle errors, handle requests for usage and version help, and invoke the business logic.
939-
Applications can call <code>System.exit</code> with the returned exit code to signal success or failure to their caller.</p>
947+
<p>Implement <code>Runnable</code> or <code>Callable</code> and your command can be <a href="#execute">executed</a> in one line of code. The example <code>main</code> method calls <code>CommandLine.execute</code> to parse the command line, handle errors, handle requests for usage and version help, and invoke the business logic. Applications can call <code>System.exit</code> with the returned exit code to signal success or failure to their caller.</p>
940948
</div>
941949
<div class="paragraph">
942950
<p>The <a href="#_mixin_standard_help_options">mixinStandardHelpOptions</a> attribute adds <code>--help</code> and <code>--version</code> options to your application.</p>
943951
</div>
944952
</div>
945953
</div>
954+
</div>
946955
<div class="sect1">
947956
<h2 id="_getting_started"><a class="anchor" href="#_getting_started"></a>2. Getting Started</h2>
948957
<div class="sectionbody">
@@ -3149,7 +3158,7 @@ <h3 id="_mutually_exclusive_options"><a class="anchor" href="#_mutually_exclusiv
31493158
<div class="sect2">
31503159
<h3 id="_mutually_dependent_options"><a class="anchor" href="#_mutually_dependent_options"></a>8.2. Mutually Dependent Options</h3>
31513160
<div class="sect3">
3152-
<h4 id="_overview"><a class="anchor" href="#_overview"></a>8.2.1. Overview</h4>
3161+
<h4 id="_overview_2"><a class="anchor" href="#_overview_2"></a>8.2.1. Overview</h4>
31533162
<div class="paragraph">
31543163
<p>Annotate a field or method with <code>@ArgGroup(exclusive = false)</code> to create a group of dependent options and positional parameters that must co-occur. For example:</p>
31553164
</div>
@@ -10190,7 +10199,7 @@ <h2 id="_generate_man_page_documentation"><a class="anchor" href="#_generate_man
1019010199
<p>See the <a href="https://github.com/remkop/picocli/tree/master/picocli-codegen#generate-documentation">Generate Documentation</a> section of the <a href="https://github.com/remkop/picocli/tree/master/picocli-codegen">picocli-codegen README</a> for details on how to generate and customize this documentation.</p>
1019110200
</div>
1019210201
<div class="paragraph">
10193-
<p>The man pages for the picocli built-in tools were created with this tool:</p>
10202+
<p>To see some examples, the man pages for the picocli built-in tools were created with this tool:</p>
1019410203
</div>
1019510204
<div class="ulist">
1019610205
<ul>
@@ -10989,7 +10998,7 @@ <h3 id="_source"><a class="anchor" href="#_source"></a>37.5. Source</h3>
1098910998
<div id="footer">
1099010999
<div id="footer-text">
1099111000
Version 4.5.1<br>
10992-
Last updated 2020-08-26 12:49:06 +0900
11001+
Last updated 2020-09-13 12:00:12 +0900
1099311002
</div>
1099411003
</div>
1099511004
</body>

0 commit comments

Comments
 (0)