#!/usr/bin/env lua

local alt_getopt = require "alt_getopt"

local long_opts = {
   verbose = "v",
   help    = "h",
   fake    = 0,
   len     = 1,
   output  = "o",
   set_value = "S",
   ["set-output"] = "o"
}

local opts
local optarg
local optind
opts,optind,optarg = alt_getopt.get_ordered_opts (arg, "hVvo:n:S:", long_opts)
for i,v in ipairs (opts) do
   if optarg [i] then
      io.write ("option `" .. v .. "': " .. optarg [i] .. "\n")
   else
      io.write ("option `" .. v .. "'\n")
   end
end

optarg,optind = alt_getopt.get_opts (arg, "hVvo:n:S:", long_opts)
local fin_options = {}
for k,v in pairs (optarg) do
   table.insert (fin_options, "fin-option `" .. k .. "': " .. v .. "\n")
end
table.sort (fin_options)
io.write (table.concat (fin_options))

for i = optind,#arg do
   io.write (string.format ("ARGV [%s] = %s\n", i, arg [i]))
end
