diff --git a/src/Lean/Elab/BuiltinCommand.lean b/src/Lean/Elab/BuiltinCommand.lean index 64ab21f3b95d..66d21a068ffa 100644 --- a/src/Lean/Elab/BuiltinCommand.lean +++ b/src/Lean/Elab/BuiltinCommand.lean @@ -12,6 +12,7 @@ import Lean.Elab.Eval import Lean.Elab.Command import Lean.Elab.Open import Lean.Elab.SetOption +import Init.System.Platform namespace Lean.Elab.Command @@ -404,6 +405,16 @@ def failIfSucceeds (x : CommandElabM Unit) : CommandElabM Unit := do includedVars := sc.includedVars.filter (!omittedVars.contains ·) } | _ => throwUnsupportedSyntax +@[builtin_command_elab version] def elabVersion : CommandElab := fun _ => do + let mut target := System.Platform.target + if target.isEmpty then target := "unknown" + -- Only one should be set, but good to know if multiple are set in error. + let platforms := + (if System.Platform.isWindows then [" Windows"] else []) + ++ (if System.Platform.isOSX then [" macOS"] else []) + ++ (if System.Platform.isEmscripten then [" Emscripten"] else []) + logInfo m!"Lean {Lean.versionString}\nTarget: {target}{String.join platforms}" + @[builtin_command_elab Parser.Command.exit] def elabExit : CommandElab := fun _ => logWarning "using 'exit' to interrupt Lean" diff --git a/src/Lean/Parser/Command.lean b/src/Lean/Parser/Command.lean index f40914433636..322ad1865349 100644 --- a/src/Lean/Parser/Command.lean +++ b/src/Lean/Parser/Command.lean @@ -505,6 +505,9 @@ Displays all available tactic tags, with documentation. -/ @[builtin_command_parser] def printTacTags := leading_parser "#print " >> nonReservedSymbol "tactic " >> nonReservedSymbol "tags" +/-- Shows the current Lean version. Prints `Lean.versionString`. -/ +@[builtin_command_parser] def version := leading_parser + "#version" @[builtin_command_parser] def «init_quot» := leading_parser "init_quot" def optionValue := nonReservedSymbol "true" <|> nonReservedSymbol "false" <|> strLit <|> numLit