# note

xrc:mod:lib     mac         note/ls

___x_cmd_mac_note(){
    [ $# -gt 0 ]    ||          set -- ls

    local op="$1";              shift
    case "$op" in
        -h|--help)  ___x_cmd help -m mac note       "$@" ; return 0 ;;
        ls)         ___x_cmd_mac_note_ls            "$@"            ;;
        add|rm)     ___x_cmd_mac_note_"${op}"       "$@"            ;;
        open)       ___x_cmd_mac_note_run open_note "$@"            ;;

        get|add_note|add_folder|\
        add_note_in_folder|add_note_in_child_folder|\
        rm_note|rm_folder|\
        rm_note_in_folder|rm_note_in_child_folder|\
        exists_note|exists_folder|open_note)
                    ___x_cmd_mac_note_run "$op" "$@"                ;;
        open_new)   ___x_cmd_mac_note_open_new  "$@"                ;;


        *)          N=mac M="Unknown subcommand: $op" log:ret:64    ;;
    esac
}

___x_cmd_mac_note_add(){
    case "$1" in
        -h|--help)  ___x_cmd help -m mac note   add ; return 0 ;;
    esac
    if [ "$#" -eq 1 ];then
        ___x_cmd_mac_note_run add_note "$@"
    elif [ "$#" -eq 2 ];then
        ___x_cmd_mac_note_run add_note_in_folder "$@"
    else
        ___x_cmd_mac_note_run add_note_in_child_folder "$@"
    fi
}

___x_cmd_mac_note_rm(){
    case "$1" in
        -h|--help)  ___x_cmd help -m mac note   rm ; return 0 ;;
    esac
    if [ "$#" -eq 1 ];then
        ___x_cmd_mac_note_run rm_note "$@"
    elif [ "$#" -eq 2 ];then
        ___x_cmd_mac_note_run rm_note_in_folder "$@"
    else
        ___x_cmd_mac_note_run rm_note_in_child_folder "$@"
    fi
}

___x_cmd_mac_note_run(){
    local script="$1"; shift
    [ "$#" -gt 0 ] || N=mac M="No argument for $script" log:ret:64
    case "$1" in
        -h|--help)  ___x_cmd help -m mac note       "$script" ; return 0 ;;
    esac
    ___x_cmd_cmds osascript "$___X_CMD_ROOT_MOD/mac/lib/note/script/${script}.applescript" "$@"
}

___x_cmd_mac_note_open_new(){
    case "$1" in
        -h|--help)  ___x_cmd help -m mac note   open_new ; return 0 ;;
    esac
    ___x_cmd_cmds osascript "$___X_CMD_ROOT_MOD/mac/lib/note/script/open_new_note.applescript" "$@"
}
