There is now a macro for this.
https://docs.julialang.org/en/v1/manual/command-line-interface/#The-Main.main-entry-point
# main.jl
function (@main)(args)
# only runs when `main.jl` is executed like a binary, in other words
#
# $ julia main.jl arguments go here
end