nitc :: CmdManOptions :: defaultinit
class CmdManOptions
super CmdManFile
# Options description
var options: nullable ArrayMap[String, String]
redef fun init_command do
var res = super
if not res isa CmdSuccess then return res
var mentity = self.mentity.as(not null)
var file = self.file.as(not null)
var options = new ArrayMap[String, String]
var lines = file.to_path.read_lines
var in_options = false
for i in [0 .. lines.length[ do
var line = lines[i]
if line == "# OPTIONS" then
in_options = true
else if in_options and line.has_prefix("### ") then
var opt = line.substring(4, line.length).trim.replace("`", "")
var desc = ""
if i < lines.length - 1 then
desc = lines[i + 1].trim
end
options[opt] = desc
else if line.has_prefix("# ") then
in_options = false
end
end
if options.is_empty then return new WarningNoManOptions(mentity)
self.options = options
return res
end
end
src/doc/commands/commands_main.nit:288,1--325,3