<commit_before># ellipsis.bash
#
# Core ellipsis interface.

load fs
load git
load pkg
load utils

# List all installed packages.
ellipsis.list_packages() {
    if ! fs.folder_empty $ELLIPSIS_PACKAGES; then
        echo $ELLIPSIS_PACKAGES/*
    fi
}

# Run commands across all packages.
ellipsis.each() {
    # execute command for ellipsis first
    pkg.init $ELLIPSIS_PATH
    "$@"
    pkg.del

    # loop over packages, excecuting command
    for pkg in $(ellipsis.list_packages); do
        pkg.init "$pkg"
        "$@"
        pkg.del
    done
}

# Installs new ellipsis package, using install hook if one exists. If no hook is
# defined, all files are symlinked into ELLIPSIS_HOME using `fs.link_files`.
ellipsis.install() {
    if [ $# -lt 1 ]; then
        log.error "No package specified for install"
        exit 1
    fi

    for package in "$@"; do
        # split branch from package name (if possible)
        parts=($(pkg.split_name "$package"))
        PKG_RAW="${parts[0]}"
        PKG_BRANCH="${parts[1]}"

        if [ -e "$PKG_RAW" ]; then
            PKG_URL="$PKG_RAW"
            PKG_NAME="$(pkg.name_from_url $PKG_URL)"
        else
            case "$PKG_RAW" in
                ssh://git)
                    # Set correct url by restoring first '@' coming from
                    # 'ssh://git@...'
                    PKG_URL="${parts[0]}@${parts[1]}"
                    PKG_NAME="$(pkg.name_from_url $PKG_URL)"
                    # Set correct branch
                    PKG_BRANCH="${parts[2]}"
                ;;
                # 'ssh:*' still included because user could be handled in
                # ~/.ssh/config
                http:*|https:*|git:*|ssh:*)
                    PKG_URL="$PKG_RAW"
                    PKG_NAME="$(pkg.name_from_url $PKG_URL)"
                ;;
                */*)
                    PKG_USER="$(pkg.user_from_shorthand $PKG_RAW)"
                    PKG_NAME="$(pkg.name_from_shorthand $PKG_RAW)"
                    PKG_URL="$ELLIPSIS_PROTO://github.com/$PKG_USER/dot-$(pkg.name_stripped $PKG_NAME)"
                ;;
                *)
                    PKG_NAME="$PKG_RAW"
                    PKG_URL="$ELLIPSIS_PROTO://github.com/$ELLIPSIS_USER/dot-$(pkg.name_stripped $PKG_NAME)"
                ;;
            esac
        fi

        # strip leading dot- from name as a convenience
        PKG_NAME=$(pkg.name_stripped $PKG_NAME)
        PKG_PATH="$(pkg.path_from_name $PKG_NAME)"

        if [ -z "$PKG_BRANCH" ]; then
            git.clone "$PKG_URL" "$PKG_PATH"
        else
            git.clone "$PKG_URL" "$PKG_PATH" --branch "$PKG_BRANCH"
        fi

        pkg.init "$PKG_PATH"
        pkg.run_hook "link"
        pkg.run_hook "install"
        pkg.del
    done
}

# Uninstall package, using uninstall hook if one exists. If no hook is
# defined, all symlinked files in ELLIPSIS_HOME are removed and package is rm -rf'd.
ellipsis.uninstall() {
    if [ $# -ne 1 ]; then
        log.error "No package specified for uninstall"
        exit 1
    fi

    pkg.init "$1"
    pkg.run_hook "uninstall"
    pkg.del
}

# Re-link unlinked packages.
ellipsis.link() {
    if [ $# -ne 1 ]; then
        log.error "No package specified to link"
        exit 1
    fi

    pkg.init "$1"
    pkg.run_hook "link"
    pkg.del
}

# Unlink package, using unlink hooks, using unlink hook if one exists. If no
# hook is defined, all symlinked files in ELLIPSIS_HOME are removed.
ellipsis.unlink() {
    if [ $# -ne 1 ]; then
        log.error "No package specified to unlink"
        exit 1
    fi

    pkg.init "$1"
    pkg.run_hook "unlink"
    pkg.del
}

# List installed packages.
ellipsis.installed() {
    if utils.cmd_exists column; then
        ellipsis.each pkg.run_hook "installed" | column -t -s $'\t'
    else
        ellipsis.each pkg.run_hook "installed"
    fi
}

# List(s) package git status.
ellipsis.status() {
    if [ $# -eq 1 ]; then
        pkg.init "$1"
        pkg.run_hook "status"
        pkg.del
    else
        ellipsis.each pkg.run_hook "status"
    fi
}

# Updates package(s) with git pull.
ellipsis.pull() {
    if [ $# -eq 1 ]; then
        pkg.init "$1"
        pkg.run_hook "pull"
        pkg.del
    else
        ellipsis.each pkg.run_hook "pull"
    fi<commit_msg>Added option to only pull ellipsis<commit_after># ellipsis.bash
#
# Core ellipsis interface.

load fs
load git
load pkg
load utils

# List all installed packages.
ellipsis.list_packages() {
    if ! fs.folder_empty $ELLIPSIS_PACKAGES; then
        echo $ELLIPSIS_PACKAGES/*
    fi
}

# Run commands across all packages.
ellipsis.each() {
    # execute command for ellipsis first
    pkg.init $ELLIPSIS_PATH
    "$@"
    pkg.del

    # loop over packages, excecuting command
    for pkg in $(ellipsis.list_packages); do
        pkg.init "$pkg"
        "$@"
        pkg.del
    done
}

# Installs new ellipsis package, using install hook if one exists. If no hook is
# defined, all files are symlinked into ELLIPSIS_HOME using `fs.link_files`.
ellipsis.install() {
    if [ $# -lt 1 ]; then
        log.error "No package specified for install"
        exit 1
    fi

    for package in "$@"; do
        # split branch from package name (if possible)
        parts=($(pkg.split_name "$package"))
        PKG_RAW="${parts[0]}"
        PKG_BRANCH="${parts[1]}"

        if [ -e "$PKG_RAW" ]; then
            PKG_URL="$PKG_RAW"
            PKG_NAME="$(pkg.name_from_url $PKG_URL)"
        else
            case "$PKG_RAW" in
                ssh://git)
                    # Set correct url by restoring first '@' coming from
                    # 'ssh://git@...'
                    PKG_URL="${parts[0]}@${parts[1]}"
                    PKG_NAME="$(pkg.name_from_url $PKG_URL)"
                    # Set correct branch
                    PKG_BRANCH="${parts[2]}"
                ;;
                # 'ssh:*' still included because user could be handled in
                # ~/.ssh/config
                http:*|https:*|git:*|ssh:*)
                    PKG_URL="$PKG_RAW"
                    PKG_NAME="$(pkg.name_from_url $PKG_URL)"
                ;;
                */*)
                    PKG_USER="$(pkg.user_from_shorthand $PKG_RAW)"
                    PKG_NAME="$(pkg.name_from_shorthand $PKG_RAW)"
                    PKG_URL="$ELLIPSIS_PROTO://github.com/$PKG_USER/dot-$(pkg.name_stripped $PKG_NAME)"
                ;;
                *)
                    PKG_NAME="$PKG_RAW"
                    PKG_URL="$ELLIPSIS_PROTO://github.com/$ELLIPSIS_USER/dot-$(pkg.name_stripped $PKG_NAME)"
                ;;
            esac
        fi

        # strip leading dot- from name as a convenience
        PKG_NAME=$(pkg.name_stripped $PKG_NAME)
        PKG_PATH="$(pkg.path_from_name $PKG_NAME)"

        if [ -z "$PKG_BRANCH" ]; then
            git.clone "$PKG_URL" "$PKG_PATH"
        else
            git.clone "$PKG_URL" "$PKG_PATH" --branch "$PKG_BRANCH"
        fi

        pkg.init "$PKG_PATH"
        pkg.run_hook "link"
        pkg.run_hook "install"
        pkg.del
    done
}

# Uninstall package, using uninstall hook if one exists. If no hook is
# defined, all symlinked files in ELLIPSIS_HOME are removed and package is rm -rf'd.
ellipsis.uninstall() {
    if [ $# -ne 1 ]; then
        log.error "No package specified for uninstall"
        exit 1
    fi

    pkg.init "$1"
    pkg.run_hook "uninstall"
    pkg.del
}

# Re-link unlinked packages.
ellipsis.link() {
    if [ $# -ne 1 ]; then
        log.error "No package specified to link"
        exit 1
    fi

    pkg.init "$1"
    pkg.run_hook "link"
    pkg.del
}

# Unlink package, using unlink hooks, using unlink hook if one exists. If no
# hook is defined, all symlinked files in ELLIPSIS_HOME are removed.
ellipsis.unlink() {
    if [ $# -ne 1 ]; then
        log.error "No package specified to unlink"
        exit 1
    fi

    pkg.init "$1"
    pkg.run_hook "unlink"
    pkg.del
}

# List installed packages.
ellipsis.installed() {
    if utils.cmd_exists column; then
        ellipsis.each pkg.run_hook "installed" | column -t -s $'\t'
    else
        ellipsis.each pkg.run_hook "installed"
    fi
}

# List(s) package git status.
ellipsis.status() {
    if [ $# -eq 1 ]; then
        pkg.init "$1"
        pkg.run_hook "status"
        pkg.del
    else
        ellipsis.each pkg.run_hook "status"
    fi
}

# Updates package(s) with git pull.
ellipsis.pull() {
    if [ $# -eq 1 ]; then
        if [[ "$1" =~ ^[Ee]llipsis$ ]]; then
            pkg.init $ELLIPSIS_PATH
        else
            pkg.init "$1"
        fi

        pkg.run_hook "pull"
        pkg.del
    else
        ellipsis.each pkg.run_hook "pull"
    fi
{'fraction_non_alphanumeric': 0.11645336100541911, 'fraction_numerical': 0.004727314654675429, 'mean_word_length': 1.8043970255415454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4073385', 'n_tokens_mistral': 3008, 'n_tokens_neox': 2830, 'n_words': 730}