App-dozo

 view release on metacpan or  search on metacpan

script/dozo  view on Meta::CPAN

    [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == true ]] || return
    local dir="$(git rev-parse --show-superproject-working-tree)"
    [[ $dir ]] || dir="$(git rev-parse --show-toplevel)"
    echo "$dir"
}

get_ip() {
    local ip=$(ifconfig 2>/dev/null | awk '/inet /{print $2}' | tail -1)
    echo "$ip"
}

container_name() {
    local name
    if [[ ${given_name:-} ]]
    then
        name="$given_name"
    else
        if [[ ${image:-} =~ (.*/)?([-_.a-zA-Z0-9]+) ]]
        then name=${BASH_REMATCH[2]}
        else name=$myname
        fi
        local dir="${mount_dir:-$cwd}"
        [[ $dir ]] && name+=.${dir##*/}
    fi
    echo "$name"
}

docker_find() {
    local OPT OPTARG OPTIND status=() id
    while getopts "s:" OPT
    do
        case $OPT in
            s) status+=("$OPTARG") ;;
        esac
    done
    shift $((OPTIND - 1))
    id=$(command docker ps -a -q ${status[@]/#/-f status=} -f name="^/$1\$")
    [[ $id ]] && echo "$id" || return 1
}

docker_status() {
    command docker inspect --format='{{.State.Status}}' $1
}

docker() {
    debug "docker $*"
    if [[ ${dryrun:-} ]]; then
        echo docker "$@"
        return 0
    fi
    command docker "$@"
}

##############################################################################
# Main
##############################################################################

# Default environment variables to inherit
DEFAULT_ENV=(
    LANG TZ
    HTTP_PROXY HTTPS_PROXY
    http_proxy https_proxy
    TERM_PROGRAM TERM_BGCOLOR COLORTERM
    DEEPL_AUTH_KEY
    OPENAI_API_KEY
    ANTHROPIC_API_KEY
    LLM_PERPLEXITY_KEY
)

# Initialize variables
top_dir=$(git_topdir) || top_dir=
cwd=$(pwd)
default_image=tecolicom/xlate
hostname=
workdir=/work
localtime=/etc/localtime
detach=
mount_dir=
container=
relative=
display=

# Set default volume based on git directory
if [[ $top_dir && $top_dir != $cwd ]]; then
    mount_dir="$top_dir"
fi

##############################################################################
# Read .dozorc
##############################################################################

# Collect .dozorc paths in reverse priority order (lowest first)
declare -a rcpath=()
[[ $HOME != $cwd ]] && rcpath+=("$HOME")
[[ $top_dir && $top_dir != $cwd ]] && rcpath+=("$top_dir")
rcpath+=(.)

# Collect options from .dozorc files
declare -a rc_opts=()
for dir in "${rcpath[@]}"; do
    rc="$dir/.dozorc"
    [[ -r $rc ]] || continue
    warn "reading $rc"
    while IFS= read -r line; do
        [[ $line =~ ^# ]] && continue
        [[ $line ]] || continue
        while IFS= read -r -d '' arg; do
            rc_opts+=("$arg")
        done < <(xargs printf '%s\0' <<< "$line")
    done < "$rc"
done

##############################################################################
# Option definitions
##############################################################################

define USAGE <<END
Dôzo - Generic Docker Runner

Usage: $myname [ options ] [ command ... ]
END

script/dozo  view on Meta::CPAN


=item * B<Side-by-side diff> - C<git diff>, C<git log>, and C<git show>
use B<sdif> for word-level side-by-side comparison

=item * B<Colorful blame> - C<git blame> uses B<greple> for enhanced
label coloring

=item * B<Office document diff> - Compare Word (.docx), Excel (.xlsx),
and PowerPoint (.pptx) files directly with git

=item * B<PDF diff> - View PDF metadata changes

=item * B<JSON diff> - Normalized JSON comparison using B<jq>

=back

=head2 Additional Utilities

=over 4

=item * B<MeCab> - Japanese morphological analyzer with IPA dictionary

=item * B<poppler-utils> - PDF processing tools (pdftotext, etc.)

=item * B<jq>, B<yq> - JSON and YAML processors

=back

=head2 Environment

=over 4

=item * Based on Ubuntu with Japanese locale (ja_JP.UTF-8)

=item * Perl and Python3 runtime environments

=item * Common API keys are automatically inherited from host
(DEEPL_AUTH_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.)

=back

=head1 ENVIRONMENT

=head2 Configuration Variables

=over 4

=item C<DOZO_DEFAULT_IMAGE>

Specifies the default Docker image used when C<-D> (C<--default>) option
is given. If not set, C<tecolicom/xlate:VERSION> is used where VERSION
is the current Dôzo version.

=back

=head2 Inherited Variables

The following environment variables are inherited by default:

    LANG TZ
    HTTP_PROXY HTTPS_PROXY http_proxy https_proxy
    TERM_PROGRAM TERM_BGCOLOR COLORTERM
    DEEPL_AUTH_KEY OPENAI_API_KEY ANTHROPIC_API_KEY LLM_PERPLEXITY_KEY

=head2 Container Variables

The following environment variables are set inside the container:

=over 4

=item C<DOZO_RUNNING_ON_DOCKER=1>

Indicates the command is running inside a container started by Dôzo.

=item C<XLATE_RUNNING_ON_DOCKER=1>

For compatibility with xlate. Used to prevent recursive Docker
invocation when xlate is run inside the container.

=back

=head1 SEE ALSO

L<xlate>, L<App::Greple::xlate>

L<getoptlong.sh|https://github.com/tecolicom/getoptlong>

=head1 AUTHOR

Kazumasa Utashiro

=head1 LICENSE

Copyright © 2025-2026 Kazumasa Utashiro.

This software is released under the MIT License.
L<https://opensource.org/licenses/MIT>

=cut



( run in 0.972 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )