Console Companions forked from Project Abraxas
This repository has been archived on 2026-06-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
Find a file
2026-06-14 14:26:06 +09:00
.vscode Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
gradle Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
src Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
.gitignore Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
AGENTS.md Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
build.gradle.kts Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
gradlew Okay, I understand. This diff represents a set of changes aimed at updating a Gradle project, including upgrading Gradle itself, its wrapper, dependencies, and related configurations. Here's a breakdown of the changes, why they're likely being made, and what they mean: 2025-03-01 16:30:59 +09:00
gradlew.bat Okay, I understand. This diff represents a set of changes aimed at updating a Gradle project, including upgrading Gradle itself, its wrapper, dependencies, and related configurations. Here's a breakdown of the changes, why they're likely being made, and what they mean: 2025-03-01 16:30:59 +09:00
LICENSE Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
README.md Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00
settings.gradle.kts Refactor Helper interface and add utility methods for string formatting and array joining 2026-06-09 04:02:54 +09:00

Project Console

Project Console은 Java 환경에서 콘솔 입출력(I/O)과 명령행 인자(CLI Arguments) 파싱을 쉽고 효율적으로 처리할 수 있도록 설계된 경량 유틸리티 라이브러리입니다.

Features

  • 유연한 Args 파서: -key=value, --key value, -flag 등 표준적인 CLI 포맷을 지원하며, 계층 구조(dot-notation) 파싱을 지원합니다.
  • JSON 상호 변환: 파싱된 인자를 중첩된 JSON 구조로 변환하거나, JSON 문자열로부터 인자 객체를 생성할 수 있습니다.
  • 직관적인 Console I/O: System.outScanner를 래핑하여 타입별 입력 및 형식화된 출력을 간소화합니다.
  • 비동기 입력 및 타임아웃: 입력 대기 시간을 제한할 수 있는 타임아웃 기능을 제공합니다.
  • SLF4J 스타일 포매팅: {} 플레이스홀더를 사용한 직관적인 문자열 포매팅을 지원합니다.

1. Console I/O

Console 클래스는 표준 입출력을 처리하기 위한 정적 메서드를 제공합니다.

import com.elex_project.console.Console;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

// 형식화된 출력 (SLF4J 스타일)
Console.writeLine("Hello, {}!", "World");

// 타입별 입력 처리 및 재시도 로직 포함
int age = Console.readInt("나이를 입력하세요:");

// 타임아웃이 있는 입력 처리
try {
    String response = Console.readLine(5, TimeUnit.SECONDS);
    Console.writeLine("입력값: {}", response);
} catch (TimeoutException e) {
    Console.writeLine("입력 시간이 초과되었습니다.");
}

// 보안이 필요한 입력 (패스워드)
char[] password = Console.readPassword("비밀번호:");

Key Methods

  • writeLine(String format, Object... params): Formatted output using {}.
  • readInt(), readDouble(), readBoolean(): Typed input reading.
  • readPassword(): Secure password entry (works in real terminals).

Args

Parse String[] args from main method into an easy-to-use object.

Supported Formats

  • option
  • -option
  • --option
  • -option:value
  • -option=value
  • --option=value
  • -option value
  • --option value

Example

public static void main(String... args) {
    Args parsedArgs = Args.parse(args);
    
    if (parsedArgs.has("verbose")) {
        Console.writeLine("Verbose mode enabled.");
    }
    
    String msg = parsedArgs.get("message").orElse("Default Message");
    Console.writeLine("Message: {}", msg);
}

라이선스

이 프로젝트는 Apache License 2.0에 따라 라이선스가 부여됩니다. 상세 내용은 LICENSE 파일을 참조하세요.


© 2026 Elex Co., Pte. All rights reserved.