List of usage examples for org.apache.hadoop.fs.shell Command getUsage
public String getUsage()
From source file:com.ruizhan.hadoop.hdfs.FsShell.java
License:Apache License
private void printInfo(PrintStream out, String cmd, boolean showHelp) { if (cmd != null) { // display help or usage for one command Command instance = commandFactory.getInstance("-" + cmd); if (instance == null) { throw new UnknownCommandException(cmd); }/* w w w . ja v a 2 s . c om*/ if (showHelp) { printInstanceHelp(out, instance); } else { printInstanceUsage(out, instance); } } else { // display help or usage for all commands out.println(usagePrefix); // display list of short usages ArrayList<Command> instances = new ArrayList<Command>(); for (String name : commandFactory.getNames()) { Command instance = commandFactory.getInstance(name); if (!instance.isDeprecated()) { System.out.println("\t[" + instance.getUsage() + "]"); instances.add(instance); } } // display long descriptions for each command if (showHelp) { for (Command instance : instances) { out.println(); printInstanceHelp(out, instance); } } out.println(); ToolRunner.printGenericCommandUsage(out); } }
From source file:com.ruizhan.hadoop.hdfs.FsShell.java
License:Apache License
private void printInstanceUsage(PrintStream out, Command instance) { out.println(usagePrefix + " " + instance.getUsage()); }
From source file:com.ruizhan.hadoop.hdfs.FsShell.java
License:Apache License
private void printInstanceHelp(PrintStream out, Command instance) { boolean firstLine = true; for (String line : instance.getDescription().split("\n")) { String prefix;/*from w ww.ja v a 2s . c o m*/ if (firstLine) { prefix = instance.getUsage() + ":\t"; firstLine = false; } else { prefix = "\t\t"; } System.out.println(prefix + line); } }