|
1 | 1 | --- |
2 | 2 | date: '2026-01-11T15:00:00+01:00' |
3 | 3 | draft: false |
4 | | -title: 'Æsh, Another Extendable SHell' |
| 4 | +title: 'Æsh - Java Libraries for Command-Line Interfaces' |
5 | 5 | --- |
6 | 6 |
|
7 | | -Æsh is a collection of Java libraries for building powerful command-line interfaces and console applications. |
| 7 | +Æsh (Another Extendable SHell) is a collection of Java libraries for building command-line interfaces, interactive shells, and terminal applications. |
8 | 8 |
|
9 | | -## Projects |
| 9 | +## Overview |
10 | 10 |
|
11 | | -### Æsh |
12 | | -A library to easily create commands through a well-defined API. Æsh handles all parsing, validation, and injection for your commands. |
| 11 | +The Æsh project provides two complementary libraries: |
13 | 12 |
|
14 | | -### Æsh Readline |
15 | | -A readline library supporting most GNU Readline features, including line editing, history, completion, masking, and remote connectivity. |
| 13 | +- **[Æsh](/docs/aesh)** - High-level command framework with annotation-based definitions |
| 14 | +- **[Æsh Readline](/docs/readline)** - Low-level terminal input/output and line editing |
16 | 15 |
|
17 | | -## Features |
| 16 | +Both libraries are production-ready, cross-platform (POSIX and Windows), and actively maintained. |
18 | 17 |
|
19 | | -### Æsh |
20 | | -- Easy to use API to create everything from simple to advanced commands |
21 | | -- Support for different types of options (list, group, single) and arguments |
22 | | -- Built-in completors for default values, booleans and files |
23 | | -- Multiple hierarchy of sub commands (eg: `git rebase/pull`) |
24 | | -- Automatic injection of option values and arguments during execution |
25 | | -- Custom validators, activators, completors, converters, renderers and parsers |
26 | | -- Automatically generates help/info text based on metadata |
27 | | -- Add and remove commands during runtime |
| 18 | +## Æsh - Command Framework |
28 | 19 |
|
29 | | -### Æsh Readline |
30 | | -- Line editing with undo/redo |
31 | | -- History (search, persistence) |
32 | | -- Completion support |
33 | | -- Password masking |
34 | | -- Paste buffer |
| 20 | +Æsh provides a high-level API for building CLI applications with commands, options, and arguments. It handles parsing, validation, type conversion, and help generation automatically. |
| 21 | + |
| 22 | +### Example |
| 23 | + |
| 24 | +```java |
| 25 | +@CommandDefinition(name = "deploy", description = "Deploy an application") |
| 26 | +public class DeployCommand implements Command<CommandInvocation> { |
| 27 | + |
| 28 | + @Option(shortName = 'e', defaultValue = "production", |
| 29 | + description = "Target environment") |
| 30 | + private String environment; |
| 31 | + |
| 32 | + @Option(shortName = 'f', hasValue = false, |
| 33 | + description = "Force deployment") |
| 34 | + private boolean force; |
| 35 | + |
| 36 | + @Argument(description = "Application name", required = true) |
| 37 | + private String application; |
| 38 | + |
| 39 | + @Override |
| 40 | + public CommandResult execute(CommandInvocation invocation) { |
| 41 | + invocation.println("Deploying " + application + " to " + environment); |
| 42 | + if (force) { |
| 43 | + invocation.println("Force flag enabled"); |
| 44 | + } |
| 45 | + return CommandResult.SUCCESS; |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +Start an interactive console or execute single commands: |
| 51 | + |
| 52 | +```java |
| 53 | +// Interactive console with history and tab completion |
| 54 | +AeshConsoleRunner.builder() |
| 55 | + .command(DeployCommand.class) |
| 56 | + .prompt("[deploy-tool]$ ") |
| 57 | + .start(); |
| 58 | + |
| 59 | +// Single command execution (for CLI tools) |
| 60 | +AeshRuntimeRunner.builder() |
| 61 | + .command(DeployCommand.class) |
| 62 | + .args(args) |
| 63 | + .execute(); |
| 64 | +``` |
| 65 | + |
| 66 | +### Key Capabilities |
| 67 | + |
| 68 | +**Command Definition** |
| 69 | +- Annotation-based (`@CommandDefinition`, `@Option`, `@Argument`) or builder API |
| 70 | +- Automatic parsing and type conversion (String, Integer, Boolean, File, Enum, custom types) |
| 71 | +- Support for short (`-v`) and long (`--verbose`) option names |
| 72 | +- Required and optional parameters with default values |
| 73 | + |
| 74 | +**Command Organization** |
| 75 | +- Command groups and subcommands (e.g., `git remote add`, `docker container start`) |
| 76 | +- Unlimited nesting depth for complex hierarchies |
| 77 | +- Dynamic command registration and removal at runtime |
| 78 | + |
| 79 | +**User Experience** |
| 80 | +- Automatic help generation (`--help`) |
| 81 | +- Tab completion for commands, options, and values |
| 82 | +- Built-in completers for files, booleans, enums |
| 83 | +- Command history and line editing (via Readline) |
| 84 | +- Clear error messages and validation feedback |
| 85 | + |
| 86 | +**Extensibility** |
| 87 | +- **Validators** - Custom validation rules for options and arguments |
| 88 | +- **Converters** - Convert string input to custom types |
| 89 | +- **Completers** - Domain-specific tab completion |
| 90 | +- **Activators** - Conditionally enable/disable options based on other options |
| 91 | +- **Renderers** - Customize help output format |
| 92 | + |
| 93 | +**Execution Modes** |
| 94 | +- **Console mode** - Interactive shell with readline features |
| 95 | +- **Runtime mode** - Single command execution from command-line arguments |
| 96 | +- **Programmatic** - Direct command invocation from Java code |
| 97 | + |
| 98 | +### Use Cases |
| 99 | + |
| 100 | +- CLI tools and utilities |
| 101 | +- Interactive shells and REPLs |
| 102 | +- Build systems and deployment tools |
| 103 | +- System administration utilities |
| 104 | +- Developer tools and code generators |
| 105 | + |
| 106 | +## Æsh Readline - Terminal API |
| 107 | + |
| 108 | +Æsh Readline provides low-level terminal input handling with GNU Readline compatibility. It's used by Æsh internally but can be used standalone for custom terminal applications. |
| 109 | + |
| 110 | +### Example |
| 111 | + |
| 112 | +```java |
| 113 | +TerminalConnection connection = new TerminalConnection(); |
| 114 | +Readline readline = ReadlineBuilder.builder() |
| 115 | + .history(new FileHistory(new File(".history"), 100)) |
| 116 | + .build(); |
| 117 | + |
| 118 | +read(connection, readline); |
| 119 | +connection.openBlocking(); |
| 120 | + |
| 121 | +private static void read(TerminalConnection connection, Readline readline) { |
| 122 | + readline.readline(connection, "prompt> ", input -> { |
| 123 | + if (input != null && input.equals("exit")) { |
| 124 | + connection.close(); |
| 125 | + } else { |
| 126 | + connection.write("Echo: " + input + "\n"); |
| 127 | + read(connection, readline); |
| 128 | + } |
| 129 | + }); |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +### Key Capabilities |
| 134 | + |
| 135 | +**Line Editing** |
| 136 | +- Full line editing with undo/redo support |
35 | 137 | - Emacs and Vi editing modes |
36 | | -- Cross-platform (POSIX and Windows) |
37 | | -- Configurable history file & buffer size |
38 | | -- Standard out and standard error support |
39 | | -- Redirect, alias, and pipeline support |
40 | | -- Remote connectivity (SSH, Telnet, WebSockets) |
| 138 | +- Customizable key bindings |
| 139 | +- Copy/paste with paste buffer |
| 140 | + |
| 141 | +**History Management** |
| 142 | +- Persistent history with file storage |
| 143 | +- History search (Ctrl+R) |
| 144 | +- Configurable history size |
| 145 | +- Per-session or global history |
| 146 | + |
| 147 | +**Input Features** |
| 148 | +- Tab completion with custom completers |
| 149 | +- Password masking for sensitive input |
| 150 | +- Multi-line input support |
| 151 | +- Prompt customization |
| 152 | + |
| 153 | +**Terminal Control** |
| 154 | +- Cursor positioning and movement |
| 155 | +- Screen clearing and manipulation |
| 156 | +- Color and formatting (ANSI escape sequences) |
| 157 | +- Terminal size detection |
| 158 | + |
| 159 | +**Remote Connectivity** |
| 160 | +- SSH server support (via `terminal-ssh`) |
| 161 | +- Telnet server support (via `terminal-telnet`) |
| 162 | +- WebSocket server support (via `terminal-http`) |
| 163 | +- Unified API for local and remote terminals |
| 164 | + |
| 165 | +**Platform Support** |
| 166 | +- POSIX systems (Linux, macOS, BSD) |
| 167 | +- Windows (native and WSL) |
| 168 | +- Remote terminals via SSH/Telnet/WebSocket |
| 169 | + |
| 170 | +### Use Cases |
| 171 | + |
| 172 | +- Custom terminal applications and text-based UIs |
| 173 | +- Text editors and viewers |
| 174 | +- Terminal multiplexers |
| 175 | +- Interactive shells with custom syntax |
| 176 | +- Terminal-based games and animations |
| 177 | +- Remote shell applications |
| 178 | + |
| 179 | +## Architecture |
| 180 | + |
| 181 | +``` |
| 182 | +┌──────────────────────────────────────────────┐ |
| 183 | +│ Your Application │ |
| 184 | +└──────────────┬───────────────────────────────┘ |
| 185 | + │ |
| 186 | + ├─── Uses Æsh Framework ──────────┐ |
| 187 | + │ • Command definitions │ |
| 188 | + │ • Automatic parsing │ |
| 189 | + │ • Validation & conversion │ |
| 190 | + │ • Help generation │ |
| 191 | + │ │ |
| 192 | + └─── Or Uses Readline Directly ───┤ |
| 193 | + • Terminal input/output │ |
| 194 | + • Manual command handling │ |
| 195 | + • Custom UI control │ |
| 196 | + │ |
| 197 | + ┌────────────────────────────────────┘ |
| 198 | + │ |
| 199 | + ▼ |
| 200 | +┌──────────────────────────────────────────────┐ |
| 201 | +│ Æsh Readline (Core Library) │ |
| 202 | +│ • Terminal abstraction │ |
| 203 | +│ • Line editing & history │ |
| 204 | +│ • Completion & key bindings │ |
| 205 | +│ • Connection management │ |
| 206 | +└──────────────┬───────────────────────────────┘ |
| 207 | + │ |
| 208 | + ▼ |
| 209 | +┌──────────────────────────────────────────────┐ |
| 210 | +│ Terminal / Connection Layer │ |
| 211 | +│ • Local TTY (POSIX/Windows) │ |
| 212 | +│ • SSH connections │ |
| 213 | +│ • Telnet connections │ |
| 214 | +│ • WebSocket connections │ |
| 215 | +└──────────────────────────────────────────────┘ |
| 216 | +``` |
| 217 | + |
| 218 | +**Note:** Æsh is built on top of Readline. Most users building CLI applications should use Æsh. Use Readline directly only when you need low-level terminal control. |
| 219 | + |
| 220 | +## Installation |
| 221 | + |
| 222 | +### Maven |
| 223 | + |
| 224 | +**Æsh (Command Framework):** |
| 225 | +```xml |
| 226 | +<dependency> |
| 227 | + <groupId>org.aesh</groupId> |
| 228 | + <artifactId>aesh</artifactId> |
| 229 | + <version>1.7</version> |
| 230 | +</dependency> |
| 231 | +``` |
| 232 | + |
| 233 | +**Æsh Readline (Terminal API):** |
| 234 | +```xml |
| 235 | +<dependency> |
| 236 | + <groupId>org.aesh</groupId> |
| 237 | + <artifactId>readline</artifactId> |
| 238 | + <version>3.5</version> |
| 239 | +</dependency> |
| 240 | +``` |
| 241 | + |
| 242 | +### Gradle |
| 243 | + |
| 244 | +**Æsh:** |
| 245 | +```groovy |
| 246 | +implementation 'org.aesh:aesh:1.7' |
| 247 | +``` |
| 248 | + |
| 249 | +**Readline:** |
| 250 | +```groovy |
| 251 | +implementation 'org.aesh:readline:3.5' |
| 252 | +``` |
| 253 | + |
| 254 | +## Documentation |
| 255 | + |
| 256 | +- **[Getting Started Guide](/docs)** - Choose the right library and get started |
| 257 | +- **[Æsh Documentation](/docs/aesh)** - Complete command framework reference |
| 258 | +- **[Readline Documentation](/docs/readline)** - Terminal API reference |
| 259 | +- **[Examples Repository](https://github.com/aeshell/aesh-examples)** - Working code examples |
| 260 | + |
| 261 | +## Requirements |
| 262 | + |
| 263 | +- Java 8 or later |
| 264 | +- No external dependencies (beyond JDK) |
| 265 | + |
| 266 | +## Project Resources |
| 267 | + |
| 268 | +- **GitHub Repository:** [github.com/aeshell/aesh](https://github.com/aeshell/aesh) |
| 269 | +- **Examples Repository:** [github.com/aeshell/aesh-examples](https://github.com/aeshell/aesh-examples) |
| 270 | +- **Issue Tracker:** [github.com/aeshell/aesh/issues](https://github.com/aeshell/aesh/issues) |
| 271 | +- **Discussions:** [github.com/aeshell/aesh/discussions](https://github.com/aeshell/aesh/discussions) |
| 272 | + |
| 273 | +## License |
| 274 | + |
| 275 | +Apache License 2.0 |
| 276 | + |
| 277 | +## Related Projects |
| 278 | + |
| 279 | +Æsh has been used in several open-source projects: |
| 280 | + |
| 281 | +- **WildFly** - Application server CLI |
| 282 | +- **JBoss Tools** - Command-line interfaces |
| 283 | +- Various system administration and developer tools |
| 284 | + |
| 285 | +See the [GitHub repository](https://github.com/aeshell/aesh) for more information. |
0 commit comments