* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <cstdlib>
-#include <cstring>
-
#include "args.hh"
#include "call_type.hh"
-#include "commands.hh"
+#include "command.hh"
#include "usage.hh"
int
{
Args args(argc, argv);
- if (!args.size())
- usage();
-
progname = args.pop("{progname}");
- const DispatchTable &dt = CallType::detect(args).getDispatch();
-
if (!args.size())
usage();
- const std::string &command = args.pop();
-
- for (int i = 0; i < num_commands; ++i) {
- if (command != command_table[i].name)
- continue;
+ CallType *ct = CallType::detect(args);
+ if (!ct)
+ usage();
- command_table[i].func(dt, args);
- exit(0);
- }
+ if (!Command::run(ct->getDispatch(), args))
+ usage();
- usage();
+ exit(0);
}