#!/usr/bin/env nu
# SPDX-FileCopyrightText: 2025-present Krys Lawrence <aquarion.5.krystopher@spamgourmet.org>
# SPDX-License-Identifier: AGPL-3.0-only

# Part of the aquarion-libtts library of the Aquarion AI project.
# Copyright (C) 2025-present Krys Lawrence <aquarion.5.krystopher@spamgourmet.org>
#
# This program is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free Software
# Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.


### Default commands

# Commands to more easily work with I18N / L10N translation.
def main []: nothing -> string {
    help main
}

### Grouped tasks

# Extract all strings from all relevant source files and generate PO templates.
def "main extract" []: nothing -> string {
    main extract src
    main extract tests
}

# NOTE: There is no grouped command for "init".  Those must be run individually for
# precision.

# Update all PO message catalogues based on their appropriate PO templates.
def "main update" []: nothing -> string {
    main update src
    main update tests
}

# Compile all PO message catalogues in to their binary MO formats.
def "main compile" []: nothing -> string {
    main compile src
    main compile tests
}

### Individual tasks

# Extract strings from relevant source files and generate PO templates.
def "main extract src" []: nothing -> string {
    hatch run babel:extract-src
}

# Extract strings from relevant test files and generate PO templates.
def "main extract tests" []: nothing -> string {
    hatch run babel:extract-tests
}

# Initialize a new source locale.
def "main init src" [locale: string]: nothing -> string {
    hatch run babel:init-src $locale
}

# Initialize a new test locale.
def "main init tests" [locale: string]: nothing -> string {
    hatch run babel:init-tests $locale
}

# Update source PO message catalogues based on their appropriate PO templates.
def "main update src" [--headers (-h)]: nothing -> string {
    mut extra = ""
    if $headers { $extra = "--headers" }
    hatch run babel:update-src $extra
}

# Update test PO message catalogues based on their appropriate PO templates.
def "main update tests" [--headers (-h)]: nothing -> string {
    mut extra = ""
    if $headers { $extra = "--headers" }
    hatch run babel:update-tests $extra
}

# Compile source PO message catalogues in to their binary MO formats.
def "main compile src" []: nothing -> string {
    hatch run babel:compile-src
}

# Compile test PO message catalogues in to their binary MO formats.
def "main compile tests" []: nothing -> string {
    hatch run babel:compile-tests
}
