1.1 --- a/org/sonews/daemon/command/HelpCommand.java Mon Aug 24 13:00:05 2009 +0200
1.2 +++ b/org/sonews/daemon/command/HelpCommand.java Sat May 01 18:51:57 2010 +0200
1.3 @@ -19,12 +19,14 @@
1.4 package org.sonews.daemon.command;
1.5
1.6 import java.io.IOException;
1.7 +import java.util.Set;
1.8 +import org.sonews.daemon.CommandSelector;
1.9 import org.sonews.daemon.NNTPConnection;
1.10 import org.sonews.util.io.Resource;
1.11
1.12 /**
1.13 * This command provides a short summary of the commands that are
1.14 - * understood by this implementation of the server. The help text will
1.15 + * understood by this implementation of the server. The help text will
1.16 * be presented as a multi-line data block following the 100 response
1.17 * code (taken from RFC).
1.18 * @author Christian Lins
1.19 @@ -61,13 +63,35 @@
1.20 public void processLine(NNTPConnection conn, final String line, byte[] raw)
1.21 throws IOException
1.22 {
1.23 + final String[] command = line.split(" ");
1.24 conn.println("100 help text follows");
1.25 -
1.26 - final String[] help = Resource
1.27 - .getAsString("helpers/helptext", true).split("\n");
1.28 - for(String hstr : help)
1.29 +
1.30 + if(line.length() <= 1)
1.31 {
1.32 - conn.println(hstr);
1.33 + final String[] help = Resource
1.34 + .getAsString("helpers/helptext", true).split("\n");
1.35 + for(String hstr : help)
1.36 + {
1.37 + conn.println(hstr);
1.38 + }
1.39 +
1.40 + Set<String> commandNames = CommandSelector.getCommandNames();
1.41 + for(String cmdName : commandNames)
1.42 + {
1.43 + conn.println(cmdName);
1.44 + }
1.45 + }
1.46 + else
1.47 + {
1.48 + Command cmd = CommandSelector.getInstance().get(command[1]);
1.49 + if(cmd instanceof HelpfulCommand)
1.50 + {
1.51 + conn.println(((HelpfulCommand)cmd).getHelpString());
1.52 + }
1.53 + else
1.54 + {
1.55 + conn.println("No further help information available.");
1.56 + }
1.57 }
1.58
1.59 conn.println(".");