

# x gh wf run -r x-cmd/xx fabu-yyxx.yml
# x gh -r x-cmd/xx fabu-yyxx.yml
# x gh fabu-yyxx.yml
# x gh --key value fabu-yyxx <argument>...

# x gh anyrun hi.py
# x gh anyrun hi.js
# x gh hi.py
# x gh hi.js
# x gh hi.js work abc def
# x gh anyrun init -r
# x gh folder

# x gh anyrun hi.py
# x gh anyrun .x-cmd/hi.js

# x gh anyrun .x-cmd/hi.js
# x gh anyrun ./work/SKILL.md

___x_cmd_gh_anyrun(){
    param:void

    local gharg
    arg:init:x gharg

    local repo

    while [ $# -gt 0 ]; do
        case "$1" in
            -r|--repo)  repo="$2" ;  arg:2:shift ;;
            --*)        arg:add gharg --filed "${1#--}"="$2"
                        arg:2:shift ;;
            *)          break ;;
        esac
    done

    [ -z "$repo" ] || {
        N=gh M="Please provide repo" log:ret:64
    }

    [ $# -gt 0 ]    ||  N=gh M="Please provide running target." log:ret:64

    local target="$1"

    # remote file.

    case "$target" in
        ./*|../**|/*)
            [ -f "$target" ]
            # upload the file into the artifact.
            # set the field
            arg:add gharg --filed "script"
            ;;
        *)
            ;;
    esac


    # TODO: upload the script

    eval set -- "$gharg"
    ___x_cmd_gh wf run -r "$repo" x-cmd-gh-anyryn.yml "$@"
}

___x_cmd_gh_anyrun_init(){
    :
}
