com.github.yin.cli.analysis.UsagePrinter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-cli-flags Show documentation
Show all versions of java-cli-flags Show documentation
Easy to use command-line parser, which enables you to
define cmdline flags directly the class they are used in.
The newest version!
package com.github.yin.cli.analysis;
import com.github.yin.cli.ClassMetadataIndex;
import com.github.yin.cli.FlagIndex;
import com.github.yin.cli.FlagMetadata;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Sets;
import java.io.PrintStream;
import java.util.Set;
/**
* @author yin
*/
public class UsagePrinter {
public void printUsage(FlagIndex flagMetaIndex, ClassMetadataIndex classMetaIndex, PrintStream out) {
ImmutableMultimap links = flagMetaIndex.byClass();
for (String className : links.keySet()) {
Set classFlags = Sets.newTreeSet(links.get(className));
out.println(className + ':');
if (classMetaIndex.classes().containsKey(className)) {
String desc = classMetaIndex.classes().get(className).desc();
if (desc != null && !desc.isEmpty()) {
out.println(desc);
out.println();
}
}
for (FlagMetadata link : classFlags) {
out.println("\t" + link.flagID().flagName() + "\t" + link.desc());
}
out.println();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy