nitc :: CmdManOptions :: defaultinit
nitc $ CmdManOptions :: SELF
Type of this instance, automatically specialized in every classnitc :: html_commands $ CmdManOptions :: to_html
Render results as a HTML stringnitc :: json_commands $ CmdManOptions :: to_json
Return a JSON Serializable representation ofself
results
nitc :: md_commands $ CmdManOptions :: to_md
Render results as a Markdown stringnitc :: CmdEntity :: _mentity_name
Name of the mentity this command is aboutcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: DocCommand :: cmd_filter
Return a new filter for that command execution.nitc :: CmdManFile :: defaultinit
core :: Object :: defaultinit
nitc :: CmdEntity :: defaultinit
nitc :: DocCommand :: defaultinit
nitc :: CmdManOptions :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: DocCommand :: http_init
Init the command from an HTTPRequestcore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: CmdEntity :: mentity_name
Name of the mentity this command is aboutnitc :: CmdEntity :: mentity_name=
Name of the mentity this command is aboutcore :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: DocCommand :: parser_init
Initialize the command from the CommandParser datanitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
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
redef class CmdManOptions
redef fun to_md do
var options = self.options
if options == null or options.is_empty then return ""
var tpl = new Template
tpl.addn "~~~"
for opt, desc in options do
tpl.addn "* {opt}\t\t{desc}"
end
tpl.addn "~~~"
return tpl.write_to_string
end
end
src/doc/templates/md_commands.nit:317,1--331,3
redef class CmdManOptions
redef fun to_json do
var obj = new JsonObject
obj["options"] = options
return obj
end
end
src/doc/templates/json_commands.nit:288,1--294,3
redef class CmdManOptions
redef fun execute(no_color) do
var mentity = self.mentity.as(not null).full_name
if no_color == null or not no_color then mentity = mentity.blue.bold
var title = "Options for `{mentity}`:"
if no_color == null or not no_color then
print title.bold
else
print title
end
print ""
var options = self.options.as(not null)
for opt, desc in options do
if no_color == null or not no_color then
print " * {opt.blue.bold}: {desc}"
else
print " * {opt}: {desc}"
end
end
end
end
src/doc/term/term.nit:520,1--542,3
redef class CmdManOptions
redef fun to_html do
var options = self.options
if options == null or options.is_empty then return ""
var tpl = new Template
tpl.addn "<pre>"
tpl.addn "<table width='100%'>"
for opt, desc in options do
tpl.addn "<tr>"
tpl.addn "<th valign='top' width='30%'>{opt}</th>"
tpl.addn "<td width='70%'>{desc}</td>"
tpl.addn "</tr>"
end
tpl.addn "</table>"
tpl.addn "</pre>"
return tpl.write_to_string
end
end
src/doc/templates/html_commands.nit:329,1--348,3