Skip to content

✨ Add embeddable ACKLocalizationCommand - #48

Open
olejnjak wants to merge 2 commits into
mainfrom
feature/argument-parser
Open

olejnjak wants to merge 2 commits into
mainfrom
feature/argument-parser

Conversation

@olejnjak

@olejnjak olejnjak commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Motivation

This prepares the ground for an auth command that calls the gcloud tool to update authorization (Application Default Credentials) used to access the spreadsheet. Such a command needs a proper command-line interface, so command-line handling now uses Swift Argument Parser. The command is also exposed as a library so other tools can embed it (e.g. as a subcommand).

Changes

  • ACKLocalizationCommands (new library target + product) — public ACKLocalizationCommand: AsyncParsableCommand with command name localization; instantiates ACKLocalization and runs it
  • ACKLocalization (executable) — main.swift replaced by @main extension ACKLocalizationCommand { }, the target now depends only on ACKLocalizationCommands
  • ACKLocalizationCore — ACKLocalization.run() is now async throws; instead of calling exit(1) it displays the error and rethrows it, so an embedding tool is not terminated on failure. ACKLocalizationCore itself does not depend on ArgumentParser
  • Added swift-argument-parser (from 1.8.2)

Behavior

  • Running without arguments behaves as before (same output, exit codes 0 / 1) — verified on a real project with ADC auth
  • --help is now available
  • Unknown arguments are now rejected with exit code 64 (previously silently ignored)

Breaking change for library consumers

ACKLocalization.run() now throws, callers need try.

Embedding

.product(name: "ACKLocalizationCommands", package: "ACKLocalization")
import ACKLocalizationCommands

@main
struct Tool: AsyncParsableCommand {
    static let configuration = CommandConfiguration(
        subcommands: [ACKLocalizationCommand.self]
    )
}

Command-line handling now uses Swift Argument Parser. The command
(`localization`) lives in the new ACKLocalizationCommands library so
other tools can embed it, the executable only marks it as @main.

ACKLocalization.run() now rethrows instead of calling exit(1), so an
embedding tool is not terminated on failure.
Copilot AI balanced review requested due to automatic review settings September 28, 2026 23:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The documented embedding example lacks a required ArgumentParser import and the central throwing behavior needs regression coverage.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Exposes localization CLI handling as an embeddable Swift Argument Parser command while keeping core logic parser-independent.

Changes:

  • Adds the ACKLocalizationCommands library and executable entry point.
  • Makes ACKLocalization.run() rethrow errors instead of exiting.
  • Adds Swift Argument Parser and updates documentation.
File Description
Sources/​ACKLocalizationCore/​ACKLocalization.swift Introduces the throwing execution contract.
Sources/​ACKLocalizationCommands/​ACKLocalizationCommand.swift Defines the embeddable command.
Sources/​ACKLocalization/​main.swift Removes the previous entry point.
Sources/​ACKLocalization/​ACKLocalizationCommand+Main.swift Marks the command as executable entry point.
Package.swift Adds the command library and parser dependency.
Package.resolved Pins Swift Argument Parser 1.8.2.
CHANGELOG.md Documents the API and CLI changes.
.claude/​CLAUDE.md Updates architecture guidance.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/ACKLocalizationCommands/ACKLocalizationCommand.swift
Comment thread Sources/ACKLocalizationCore/ACKLocalization.swift
@olejnjak
olejnjak requested a review from komkovla September 28, 2026 23:53
@komkovla

Copy link
Copy Markdown

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants