# shellcheck shell=sh disable=SC3043,SC2164

# author:       Li Junhao           l@x-cmd.com    edwinjhlee.github.io
# maintainer:   Li Junhao
# license:      GPLv3

# open -a ApplicationName file
# open a.json --> Using

___x_cmd_open___main(){
    # for i in "$@"; do
    #     case "$i" in
    #         -f|-i|-n|-v)    continue ;;
    #         -*)             continue ;;
    #         # /|/bin)        printf "Abort because trying to remove key file." >&2 || return 1 ;;
    #     esac
    # done

    # TODO: handle the arguments well.

    # local p="${1:-$HOME}"
    local p="${1:-$PWD}"

    [ ! -e "$p" ] || {
        [ -z "$___X_CMD_BOX_INNER_HOME" ]           ||  \
        [ "$HOME" = "$___X_CMD_BOX_INNER_HOME" ]    ||  \
        [ "${p#"${___X_CMD_BOX_INNER_HOME}"}" = "$p" ] || p="${HOME}${p#"$___X_CMD_BOX_INNER_HOME"}"
    }

    ___x_cmd_cmds open "$p"
}
