nitc :: CommandList
nitc :: CommandList :: defaultinit
nitc $ CommandList :: SELF
Type of this instance, automatically specialized in every classnitc $ CommandList :: name
Short name of the command, specified in the command linenitc :: Command :: _all_commands
nitc :: Command :: all_commands
nitc :: Command :: all_commands=
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: Command :: defaultinit
nitc :: CommandList :: defaultinit
core :: Object :: defaultinit
core :: 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.
core :: 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).
# List all installed packages
class CommandList
super Command
redef fun name do return "list"
redef fun usage do return "nitpm list"
redef fun description do return "List installed packages"
redef fun apply(args)
do
var files = nitpm_lib_dir.files
var name_to_desc = new Map[String, nullable String]
var max_name_len = 0
# Collect package info
for file in files do
var ini_path = nitpm_lib_dir / file / "package.ini"
if verbose then print "- Reading ini file at {ini_path}"
var ini = new IniFile.from_file(ini_path)
var tags = ini["package.tags"]
name_to_desc[file] = tags
max_name_len = max_name_len.max(file.length)
end
# Sort in alphabetical order
var sorted_names = name_to_desc.keys.to_a
alpha_comparator.sort sorted_names
# Print with clear columns
for name in sorted_names do
var col0 = name.justify(max_name_len+1, 0.0)
var col1 = name_to_desc[name] or else ""
var line = col0 + col1
print line.trim
end
end
end
src/nitpm.nit:305,1--342,3