Browse Source

Add --version option to Runic.main (#92)

pull/93/head
Fredrik Ekre 1 year ago committed by GitHub
parent
commit
5b62e442c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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 @@ -5,6 +5,10 @@ module Runic
using JuliaSyntax:
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
include("debug.jl")
include("JuliaSyntax.jl")

11
src/main.jl

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

7
test/runtests.jl

@ -1487,6 +1487,13 @@ end @@ -1487,6 +1487,13 @@ end
@test isempty(fd2)
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
for argv in [
String[], ["-"],

Loading…
Cancel
Save