Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a precompile workload #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
name = "DocOpt"
uuid = "968ba79b-81e4-546f-ab3a-2eecfa62a9db"
version = "0.5"
version = "0.5.1"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"

[compat]
julia = "1.3"
SnoopPrecompile = "1.0.3"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
30 changes: 28 additions & 2 deletions src/DocOpt.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
__precompile__()

module DocOpt

export docopt
Expand All @@ -22,10 +20,12 @@ end
struct DocOptLanguageError <: Exception
msg::AbstractString
end
Base.showerror(io::IO, e::DocOptLanguageError) = print(io, "DocOptLanguageError: ", e.usage)

struct DocOptExit <: Exception
usage::AbstractString
end
Base.showerror(io::IO, e::DocOptExit) = print(io, "DocOptExit: ", e.usage)

abstract type Pattern end
abstract type LeafPattern <: Pattern end
Expand Down Expand Up @@ -606,4 +606,30 @@ function docopt(doc::AbstractString,
end
end

using SnoopPrecompile

@precompile_setup begin
doc = """Naval Fate.

Usage:
naval_fate.jl ship new <name>...
naval_fate.jl ship <name> move <x> <y> [--speed=<kn>]
naval_fate.jl ship shoot <x> <y>
naval_fate.jl mine (set|remove) <x> <y> [--moored|--drifting]
naval_fate.jl -h | --help
naval_fate.jl --version

Options:
-h --help Show this screen.
--version Show version.
--speed=<kn> Speed in knots [default: 10].
--moored Moored (anchored) mine.
--drifting Drifting mine.

"""
@precompile_all_calls begin
docopt(doc, ["ship", "new", "BoatyMcBoatFace"]; version=v"2.0.0")
end
end

end # DocOpt