415827 - jetty-start / update --help text for new command line options

+ Making help actually print out
This commit is contained in:
Joakim Erdfelt 2013-08-26 13:03:34 -07:00
parent 7c21874535
commit 71e10b7bd2
2 changed files with 26 additions and 7 deletions

View File

@ -419,7 +419,7 @@ public class Main
// Show the usage information and return // Show the usage information and return
if (args.isHelp()) if (args.isHelp())
{ {
usage(); usage(true);
} }
// Show the version information and return // Show the version information and return
@ -493,8 +493,6 @@ public class Main
return; return;
} }
// execute Jetty in another JVM // execute Jetty in another JVM
if (args.isExec()) if (args.isExec())
{ {
@ -609,7 +607,7 @@ public class Main
} }
} }
private void usage() public void usage(boolean exit)
{ {
String usageResource = "org/eclipse/jetty/start/usage.txt"; String usageResource = "org/eclipse/jetty/start/usage.txt";
boolean usagePresented = false; boolean usagePresented = false;
@ -620,17 +618,29 @@ public class Main
try (InputStreamReader reader = new InputStreamReader(usageStream); BufferedReader buf = new BufferedReader(reader)) try (InputStreamReader reader = new InputStreamReader(usageStream); BufferedReader buf = new BufferedReader(reader))
{ {
usagePresented = true; usagePresented = true;
String line;
while ((line = buf.readLine()) != null)
{
System.out.println(line);
} }
} }
} }
else
{
System.out.println("No usage.txt ??");
}
}
catch (IOException e) catch (IOException e)
{ {
StartLog.debug(e); StartLog.warn(e);
} }
if (!usagePresented) if (!usagePresented)
{ {
System.err.println("ERROR: detailed usage resource unavailable"); System.err.println("ERROR: detailed usage resource unavailable");
} }
if (exit)
{
System.exit(EXIT_USAGE); System.exit(EXIT_USAGE);
} }
} }
}

View File

@ -24,6 +24,7 @@ import java.util.List;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
public class MainTest public class MainTest
@ -81,6 +82,14 @@ public class MainTest
main.listConfig(args); main.listConfig(args);
} }
@Test
@Ignore("Just a bit noisy for general testing")
public void testHelp() throws Exception
{
Main main = new Main();
main.usage(false);
}
@Test @Test
public void testWithCommandLine() throws Exception public void testWithCommandLine() throws Exception
{ {