oto/agent-ops/rules/project/domain/cli/rules.md

2.7 KiB

cli

목적 / 책임

사용자로부터 CLI 인자를 받아 파싱하고, Application을 통해 파이프라인 실행을 시작하는 진입 계층이다. 백그라운드 스케줄러의 상세 실행/등록 관리는 scheduler 도메인에서 담당한다.

포함 경로

  • lib/cli/cli.dart — CLI 루트 객체, 출력/스타일 처리
  • lib/cli/commands/command_base.dart — CLI 커맨드 공통 베이스
  • lib/cli/commands/command_manager.dart — CLI 커맨드 라우팅
  • lib/cli/commands/command_exe.dartexe 명령과 Application.build() 진입
  • lib/cli/commands/command_template.dart — 템플릿 출력
  • lib/cli/commands/command_start.dart — 시작 커맨드
  • lib/cli/commands/command_install.dart — 설치 명령
  • lib/cli/commands/install/ — PATH 등록 등 설치 보조 로직

제외 경로

  • lib/oto/ — 비즈니스 로직·파이프라인 엔진 (cli는 진입만 담당)
  • lib/cli/commands/scheduler/ — 스케줄러 실행/등록/OS별 백그라운드 처리 (scheduler 도메인)

주요 구성 요소

  • CLI (cli.dart) — CLI 루트 객체, 출력 유틸, CLIConfig
  • Printer (cli.dart) — OS별 콘솔 출력 처리
  • CommandExe-j(Jenkins), -t(test), -f(file) 플래그 파싱 → Application.build() 호출
  • CommandInstall — PATH 등록 (install/regist_path.dart)
  • CommandStart — 시작 커맨드
  • CommandTemplate — 템플릿 출력
  • CommandManager — CLI 커맨드 등록 관리

유지할 패턴

  • CLI 커맨드는 CommandBase 상속
  • CLI는 인자 파싱과 진입점 역할만 수행하고, 파이프라인 실행은 Application.build()에 위임
  • CommandExeBuildType 선택과 YAML 파일 읽기까지만 담당
  • 콘솔 출력은 CLI.print* 또는 CommandBase 출력 헬퍼를 사용
  • CLI 변경 후 dart analyze를 실행하고, CLI 진입 변경이면 최소 dart run bin/main.dart 수준의 스모크 실행 가능 여부를 확인

다른 도메인과의 경계

  • pipeline/command: cli는 Application.build()만 호출. 파이프라인·커맨드 내부를 직접 참조하지 않는다
  • core: DataComposer 호출은 Application 내부에서 이루어지며 cli는 관여하지 않는다
  • scheduler: CommandSchedulerlib/cli/commands/scheduler/**는 scheduler 도메인이다. 일반 CLI 변경에서 scheduler 내부 동작을 함께 수정하지 않는다

금지 사항

  • cli 레이어에서 Pipeline 또는 Command를 직접 인스턴스화하지 않는다
  • 비즈니스 로직을 cli 커맨드 핸들러에 넣지 않는다
  • 일반 CLI 변경에 scheduler 등록 파일, 로그 파일, OS 시작 프로그램 로직을 섞지 않는다