local arguments = parseArguments(unpack(arg))
local interactive = arguments["--interactive"]
-local rules = arguments["--rules"] or "options.lua"
-local configfile = arguments["--configfile"] or "config.mk"
+local rules = arguments["--rules"] or "options.lua"
+local configfile = arguments["--configfile"] or "config.mk"
local printendmsg = arguments["--print-instructions"]
local exportHeader = arguments["--export-header"]
local exportTerms = arguments["--export-terms"]
return function(progress, caption)
if progress ~= nil
then
- if 0.0 <= progress and progress <= 1.0 then progress = progress * 100 end
+ if 0.0 <= progress and progress <= 1.0 then
+ progress = progress * 100
+ end
return updater(progress, caption)
end
print()
local function loadDialog(name, configfile)
local dialog
local result, err = pcall(function() dialog = require "dialog" end)
- if not result
- then
- printWarning(err)
- return nil
- end
+ if not result then printWarning(err) return nil end
dialog.title = string.format("%s - %s Configuration", configfile, name)
- printInfo = dialog.msgbox
- printWarning = dialog.msgbox
- printError = dialog.msgbox
- beginProcess = dialog.gauge
+ printInfo = dialog.msgbox
+ printWarning = dialog.msgbox
+ printError = dialog.msgbox
+ beginProcess = dialog.gauge
return dialog
end
---------------------------------------------------------------------------
function Option:__init(rule, lookup, objects)
- self.name = rule.name
+ self.name = rule.name
self.caption = rule.caption
- self.help = rule.help
- self.value = rule.value
- self.symbol = rule.symbol
+ self.help = rule.help
+ self.value = rule.value
+ self.symbol = rule.symbol
self.cmdline = rule.cmdline
- self.config = rule.config
- self.export = rule.export
+ self.config = rule.config
+ self.export = rule.export
self.visible = rule.visible
- self.check = rule.check
- self.temp = rule.temp
- self.before = rule.before
- self.after = rule.after
- self.lookup = lookup or {}
+ self.check = rule.check
+ self.temp = rule.temp
+ self.before = rule.before
+ self.after = rule.after
+ self.lookup = lookup or {}
self.objects = objects or {}
if type(self.check) == "function" then setfenv(self.check, self.lookup) end
if self.symbol ~= nil and not self.temp
then
fd:write(util.align(self.symbol, "= " .. tostring(self.lookup[self.symbol]), 16) .. "\n")
- --fd:write(string.format("%s\t= %s\n", self.symbol, tostring(self.lookup[self.symbol])))
end
end
function Option:writeSedLine(fd)
if self.export
then
- local value = self:toExpandedString():gsub("/", "\\/")
+ local value = self:toExpandedString():gsub("/", "\\/")
local function writeLine(key)
key = tostring(key):gsub("/", "\\/")
fd:write(string.format("s/@%s@/%s/g\n", key, value))
end
function Option:getHelpText()
- local value = self:toString()
- local help = self.help or "No help available.\n"
- local name = self.name or "Unnamed"
+ local value = self:toString()
+ local help = self.help or "No help available.\n"
+ local name = self.name or "Unnamed"
local symbol = self:getSymbol() or "None"
- local arg = self:getArg() or "None"
+ local arg = self:getArg() or "None"
local problem = self:getProblem()
if problem then problem = "\nProblem(s):\n" .. problem
function BooleanOption:writeCppLine(fd)
if self.config
then
- local value = self.lookup[self.symbol]
+ local value = self.lookup[self.symbol]
local function writeLine(key)
-- Reverse the value if key starts with a bang.
local value = value
dialog.msgbox(value.name, value:getHelpText(), {["--no-collapse"] = true})
selected = value:getMenuItem()
else
- dialog.msgbox("No Help",
- "Sorry, no help is available for this option.")
+ dialog.msgbox("No Help", "Sorry, no help is available for this option.")
end
else
running = false
options:convertDependenciesToDependants()
checkSymbols(options:getObjects())
-if dialog
-then
+if dialog then
local action = options:runMenu()
if action == "exit" or action == "error"
then
options:saveToFile(configfile)
print("configuration saved to " .. configfile)
end
-elseif options:isValid()
-then
+elseif options:isValid() then
options:saveToFile(configfile)
else
printError("Uh oh!", [[