Skip to content

Commit

Permalink
Snabb lwAFTR version is Snabb version
Browse files Browse the repository at this point in the history
  • Loading branch information
wingo committed Aug 4, 2017
1 parent b152b59 commit b00485e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/core/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -119,7 +120,6 @@ License: <https://www.apache.org/licenses/LICENSE-2.0>
Snabb is open source software. For more information on Snabb, see
https://github.com/snabbco/snabb.]])
os.exit(0)
end

function programname (name)
Expand Down
16 changes: 4 additions & 12 deletions src/program/lwaftr/lwaftr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b00485e

Please sign in to comment.