diff --git a/src/core/main.lua b/src/core/main.lua index 9bf260ccd5..39aed20cfb 100644 --- a/src/core/main.lua +++ b/src/core/main.lua @@ -81,6 +81,7 @@ function select_program (args) usage(0) elseif opt == '-v' or opt == '--version' then version() + os.exit(0) else print("unrecognized option: "..opt) usage(1) @@ -119,7 +120,6 @@ License: Snabb is open source software. For more information on Snabb, see https://github.com/snabbco/snabb.]]) - os.exit(0) end function programname (name) diff --git a/src/program/lwaftr/lwaftr.lua b/src/program/lwaftr/lwaftr.lua index d452855f9f..a2756ed35b 100644 --- a/src/program/lwaftr/lwaftr.lua +++ b/src/program/lwaftr/lwaftr.lua @@ -2,23 +2,15 @@ module(..., package.seeall) local lib = require("core.lib") --- Retrieves latest version from CHANGELOG.md. --- Format: ## [Version] - 2017-31-12. local function latest_version() - local filename = "program/lwaftr/doc/CHANGELOG.md" - local regex = "^## %[([^%]]+)%] %- (%d%d%d%d%-%d%d%-%d%d)" - for line in io.lines(filename) do - local version, date = line:match(regex) - if version and date then return version, date end - end + local v = require('core.version') + return v.version, v.extra_version end local function show_usage(exit_code) local content = require("program.lwaftr.README_inc") - local version, date = latest_version() - if version and date then - content = ("Version: %s (%s)\n\n"):format(version, date)..content - end + require('core.main').version() + print('') print(content) main.exit(exit_code) end