How jabrena/setup-cli works
Project Type and Purpose
• This is a Java-based command-line application (“Setup CLI”) built with Maven and PicoCLI.
• Its sole purpose is to scaffold developer environment artifacts (devcontainers, editorconfigs, SDKMAN settings, GitHub Actions workflows, cursor rules, etc.) into a target repository by copying templates from its own templates folder.
High-Level Architecture and Main Components
a. CLI Engine
• Entry point: java -jar setup-*.jar launches PicoCLI.
• Parses global options (--help, version) and subcommands (e.g. init).
b. InitCommand Subcommand
• Implements the init logic (in src/main/java/info/jab/cli/InitCommand.java).
• Delegates to one or more Behavior modules based on flags (--devcontainer, --cursor, --maven, etc.).
c. Behavior Modules (Plugin-like)
• Each lives under src/main/java/info/jab/cli/behaviours/… (e.g. DevContainer, EditorConfig, GithubAction, Cursor, Maven, Sdkman, SpringCli, QuarkusCli).
• Implements a common interface: examine CLI options, fetch associated templates, and invoke IO.
d. IO/Template Service
• CopyFiles and related IO classes handle file system operations: copy, overwrite, patch.
• Read templates from templates/… on the classpath or filesystem.
e. Template Repository
• Static resources under templates/<template-name>.
• Each template folder mirrors the directory structure to be injected into the user’s project.
f. Build & Test Pipeline
• Maven wrapper (mvnw) and pom.xml configure compilation, testing (JUnit), code coverage (JaCoCo), and site reports (Surefire).
• GitHub Actions workflow (.github/workflows/maven.yaml) drives CI.
Component Interactions and Data Flow
• User invokes setup init --flags → PicoCLI parser routes to InitCommand.
• InitCommand reads requested flags and instantiates corresponding Behavior modules.
• Each Behavior requests templates from Template Repository via CopyFiles.
• CopyFiles writes/updates files in the target project directory.
• On completion, CLI prints success/failure status.
Architectural Patterns & Design Principles
• Command Pattern: PicoCLI’s subcommands decouple parsing from execution.
• Strategy/Plugin Pattern: Each Behavior module implements the same interface, making it easy to add new scaffolding types.
• Single Responsibility: CLI parsing, command logic, behavior implementations, and IO are separated into distinct packages.
• Immutable Templates: The templates directory is the single source of truth for scaffolding artifacts.
Technologies & Frameworks
• Java 17+ (configured in .sdkmanrc & .mvn/jvm.config)
• PicoCLI for command parsing
• Maven for build, test, coverage, site generation
• JBang for optional distribution (setup@jabrena)
• Ant-based UML doc generation under docs/ (using build.xml and umlgraph)