Merge "Adds --description (-d) option to ls-projects"
This commit is contained in:
@@ -41,6 +41,14 @@ OPTIONS
|
||||
If the user does not have access to any branch in the project then the
|
||||
whole project is not shown.
|
||||
|
||||
--description::
|
||||
--d::
|
||||
Allows listing of projects together with their respective
|
||||
description.
|
||||
|
||||
Line-feeds are escaped to allow ls-project to keep the
|
||||
"one project per line"-style.
|
||||
|
||||
--tree::
|
||||
-t::
|
||||
Displays project inheritance in a tree-like format.
|
||||
|
@@ -97,6 +97,9 @@ final class ListProjects extends BaseCommand {
|
||||
@Option(name = "--type", usage = "type of project")
|
||||
private FilterType type = FilterType.CODE;
|
||||
|
||||
@Option(name = "--description", aliases = {"-d"}, usage = "include description of project in list")
|
||||
private boolean showDescription;
|
||||
|
||||
private String currentTabSeparator = DEFAULT_TAB_SEPARATOR;
|
||||
|
||||
@Override
|
||||
@@ -115,6 +118,10 @@ final class ListProjects extends BaseCommand {
|
||||
throw new UnloggedFailure(1, "fatal: --tree and --show-branch options are not compatible.");
|
||||
}
|
||||
|
||||
if (showTree && showDescription) {
|
||||
throw new UnloggedFailure(1, "fatal: --tree and --description options are not compatible.");
|
||||
}
|
||||
|
||||
final PrintWriter stdout = toPrintWriter(out);
|
||||
final TreeMap<String, TreeNode> treeMap = new TreeMap<String, TreeNode>();
|
||||
try {
|
||||
@@ -184,7 +191,15 @@ final class ListProjects extends BaseCommand {
|
||||
continue;
|
||||
}
|
||||
|
||||
stdout.print(projectName.get() + "\n");
|
||||
stdout.print(projectName.get());
|
||||
|
||||
String desc;
|
||||
if (showDescription && !(desc = e.getProject().getDescription()).isEmpty()) {
|
||||
// We still want to list every project as one-liners, hence escaping \n.
|
||||
stdout.print(" - " + desc.replace("\n", "\\n"));
|
||||
}
|
||||
|
||||
stdout.print("\n");
|
||||
}
|
||||
|
||||
if (showTree && treeMap.size() > 0) {
|
||||
|
Reference in New Issue
Block a user