Skip to content

Commit 932f3bd

Browse files
authored
Add --version argument for version printing (#82)
1 parent f8d6947 commit 932f3bd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/JuliaC.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,18 @@ function _print_usage(io::IO=stdout)
7979
println(io, " --compile-ccallable Export ccallable entrypoints")
8080
println(io, " --experimental Forwarded to Julia (needed for --trim)")
8181
println(io, " --verbose Print commands and timings")
82+
println(io, " --version Print juliac and julia version")
8283
println(io, " -h, --help Show this help")
8384
println(io)
8485
println(io, "Examples:")
8586
println(io, " juliac --output-exe app ./MyApp.jl --bundle build --trim=safe")
8687
println(io, " juliac --output-lib build/libmylib --project ./MyLib.jl src/libentry.jl")
8788
end
8889

90+
function _print_version(io::IO=stdout)
91+
println(io, "juliac version $(pkgversion(JuliaC)), julia version $(VERSION)")
92+
end
93+
8994
# CLI app entrypoint for Pkg apps
9095
function _parse_cli_args(args::Vector{String})
9196
image_recipe = ImageRecipe()
@@ -166,6 +171,9 @@ function _main_cli(args::Vector{String}; io::IO=stdout)
166171
if isempty(args) || any(a -> a == "-h" || a == "--help", args)
167172
_print_usage(io)
168173
return
174+
elseif "--version" in args
175+
_print_version(io)
176+
return
169177
end
170178
img, link, bun = _parse_cli_args(args)
171179
compile_products(img)

test/cli.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,10 @@ end
137137
@test occursin("--verbose", out)
138138
@test occursin("--help", out)
139139
end
140+
141+
@testset "CLI --version" begin
142+
io = IOBuffer()
143+
JuliaC._main_cli(String["--version"]; io = io)
144+
@test String(take!(io)) ==
145+
"juliac version $(pkgversion(JuliaC)), julia version $(VERSION)\n"
146+
end

0 commit comments

Comments
 (0)