#!/usr/bin/env bash

nv_cmd_default() {
    local show_meta="yes"

    for par in "$@"
    do
    case $par in
        --no-meta)
            show_meta="no"
            ;;
    esac
    done

    echo "Available environment(s):"
    for env in $(find $(nv_get_env_full_path) -mindepth 1 -maxdepth 1 -type d | sort)
    do
        local env_name=$(nv_get_filename "$env")
        local info_file_full_path=$(nv_get_env_info_path "$env_name")
        local env_info=""
        local env_desc=""

        if [ -e "$info_file_full_path" ] && [ "$show_meta" = "yes" ]; then
            env_info=$(cat "$info_file_full_path" | tr '\n' '|' \
                            | sed 's/|$//' | sed 's/|/, /')
            env_desc="$env_name ($env_info)"
        else
            env_desc=$env_name
        fi
        echo "$env_desc"
    done
}

nv_cmd_desc() {
    echo "List environments"
}

nv_cmd_help() {
    nv_show_usage
    nv_show_desc "$(nv_cmd_desc)"
    echo ""
    echo "Options:"
    echo "  --no-meta    Do not show meta information of the environment"
}

# /* vim: set filetype=sh : */
