Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
package com.codename1.cli
Command-line applications: picocli-style annotations that the build turns into a parser, with help, version, subcommands and exit codes.
A class annotated CommandLine.Command is a command; its
fields annotated CommandLine.Option and
CommandLine.Parameters receive the arguments. The build
reads the annotations, generates the code that binds them and writes main,
so a command-line tool is a module with commands and nothing else, and it
compiles to a native executable for Linux, macOS and Windows like any
backend.
The same commands work in a backend with controllers. There the server is
the serve subcommand, and the command line with no arguments starts it as
before, so maintenance tasks such as a migration or an administrator account
ship in the server’s own binary.
Types
class Ansi | Styled terminal text, built fluently: |
class ArgSpec | What an option and a positional parameter have in common. |
interface CommandBinding | The code the build generates for one @Command class, through which the parser creates the command, sets its fields and runs it without reflection. |
class CommandLine | Parses a command line into an annotated command and runs it. |
class CommandSpec | The model of one command: its name, help text, options, positional parameters and subcommands. |
class Console | What a command needs to know about the terminal it writes to, and the entry point of the console API. |
class Key | One key press read from a terminal in raw mode, decoded from the bytes and escape sequences terminals send. |
class LiveRegion | The last few lines of the terminal, redrawn in place: what progress bars, spinners and prompts are drawn on. |
class MultiProgress | Several progress bars drawn together, one line each, for work that runs in parallel: |
class OptionSpec | The model of one option, written by the build from an CommandLine.Option. |
class PositionalParamSpec | The model of one positional parameter, written by the build from a CommandLine.Parameters. |
class ProgressBar | A progress bar with a percentage, a count, a rate and the time left: |
class Prompt | Questions a command asks the person running it: |
class Spinner | An animated indicator for work of unknown length, ending in a status line: |
class Table | Rows and columns rendered as text, aligned by the columns each cell takes on a terminal, so styled cells, wide characters and emoji line up: |
class Tree | A hierarchy rendered the way tree prints a directory: |