# shellcheck shell=dash

___x_cmd_webtop_home_ls(){
    [ $# -gt 0 ] || set -- --app

    local op="$1"; shift
    case "$op" in
        # json|csv
        --raw|--app)
            ___x_cmd_webtop_home_ls___"${op#--}" "$@" ;;
        *)
            ___x_cmd help -m webtop ls     ;;
    esac
}

___x_cmd_webtop_home_ls___json(){
    :
    # Show environment data
    # the port, and the image data
    # the init time.
}

___x_cmd_webtop_home_ls___csv(){
    ___x_cmd_webtop_home_ls___raw | {
        local id
        local port
        while read -r id; do
            port="${id#x-webtop-}"
            size="$(___x_cmd du)"
            printf "%s," "$port" ""
        done
    }
}

___x_cmd_webtop_home_ls___raw(){

    local PWD       # Try using this

    ___x_cmd_webtop_home_cd
    ___x_cmd fsiter .

}

___x_cmd_webtop_home_ls___app(){
    (
        cd "$___X_CMD_WEBTOP_HOME_DIR"
        ___x_cmd ls
    )
}
