Browse Source

Add --version option to Runic.main

pull/92/head
Fredrik Ekre 1 year ago
parent
commit
66ceb8c144
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 4
      src/Runic.jl
  2. 11
      src/main.jl
  3. 7
      test/runtests.jl

4
src/Runic.jl

@ -5,6 +5,10 @@ module Runic
using JuliaSyntax: using JuliaSyntax:
JuliaSyntax, @K_str, @KSet_str JuliaSyntax, @K_str, @KSet_str
const RUNIC_VERSION = pkgversion(@__MODULE__)
# XXX: This should probably be handled by Base.
Base.include_dependency(joinpath(pkgdir(@__MODULE__), "Project.toml"))
# Debug and assert utilities # Debug and assert utilities
include("debug.jl") include("debug.jl")
include("JuliaSyntax.jl") include("JuliaSyntax.jl")

11
src/main.jl

@ -140,11 +140,19 @@ function print_help()
-o <file>, --output=<file> -o <file>, --output=<file>
File to write formatted output to. If no output is given, or if the file File to write formatted output to. If no output is given, or if the file
is `-`, output is written to stdout. is `-`, output is written to stdout.
--version
Print Runic and julia version information.
""" """
) )
return return
end end
function print_version()
println(stdout, "runic version $(RUNIC_VERSION), julia version $(VERSION)")
return
end
function maybe_expand_directory!(outfiles, dir) function maybe_expand_directory!(outfiles, dir)
if !isdir(dir) if !isdir(dir)
# Assumed to be a file, checked when using it # Assumed to be a file, checked when using it
@ -205,6 +213,9 @@ function main(argv)
elseif x == "--help" elseif x == "--help"
print_help() print_help()
return errno return errno
elseif x == "--version"
print_version()
return errno
elseif x == "-q" || x == "--quiet" elseif x == "-q" || x == "--quiet"
quiet = true quiet = true
elseif x == "-v" || x == "--verbose" elseif x == "-v" || x == "--verbose"

7
test/runtests.jl

@ -1487,6 +1487,13 @@ end
@test isempty(fd2) @test isempty(fd2)
end end
# runic --version
let (rc, fd1, fd2) = runic(["--version"])
@test rc == 0
@test occursin("runic version $(Runic.RUNIC_VERSION), julia version $(VERSION)", fd1)
@test isempty(fd2)
end
# runic <stdin >stdout # runic <stdin >stdout
for argv in [ for argv in [
String[], ["-"], String[], ["-"],

Loading…
Cancel
Save