diff --git a/src/apps/bin/makeudfimage/Shell.cpp b/src/apps/bin/makeudfimage/Shell.cpp index 35f2974c1d..88f5b02f17 100644 --- a/src/apps/bin/makeudfimage/Shell.cpp +++ b/src/apps/bin/makeudfimage/Shell.cpp @@ -14,18 +14,28 @@ #include +#include "ConsoleListener.h" #include "Debug.h" +#include "UdfBuilder.h" Shell::Shell() + : fVerbosityLevel(VERBOSITY_HIGH) { } -void +status_t Shell::Run(int argc, char *argv[]) { DEBUG_INIT("Shell"); - _ProcessArguments(argc, argv); - PRINT(("finished\n")); + status_t error = _ProcessArguments(argc, argv); + if (!error) { + ConsoleListener listener(fVerbosityLevel); + UdfBuilder builder(listener); + builder.Build(); + } else { + _PrintHelp(); + } + RETURN(error); } status_t @@ -35,7 +45,7 @@ Shell::_ProcessArguments(int argc, char *argv[]) { // If we're given no parameters, the default settings // will do just fine if (argc < 2) - return B_OK; + RETURN(B_OK); // Handle each command line argument (skipping the first // which is just the app name) @@ -54,13 +64,29 @@ status_t Shell::_ProcessArgument(std::string arg, int argc, char *argv[]) { DEBUG_INIT_ETC("Shell", ("arg: `%s'", arg.c_str())); if (arg == "--help") { - _PrintHelp(); RETURN(B_ERROR); - } - RETURN(B_ERROR); + } else if (arg == "-v0") { + fVerbosityLevel = VERBOSITY_NONE; + } else if (arg == "-v1") { + fVerbosityLevel = VERBOSITY_LOW; + } else if (arg == "-v2") { + fVerbosityLevel = VERBOSITY_HIGH; + } else { + printf("ERROR: invalid argument `%s'\n", arg.c_str()); + printf("\n"); + RETURN(B_ERROR); + } + RETURN(B_OK); } void Shell::_PrintHelp() { - printf("usage: makeudfimage\n"); + printf("usage: makeudfimage [options]\n"); + printf("\n"); + printf("VALID ARGUMENTS:\n"); + printf(" --help: Displays this help text\n"); + printf(" -v0: Sets verbosity level to 0 (silent)\n"); + printf(" -v1: Sets verbosity level to 1 (low)\n"); + printf(" -v2: Sets verbosity level to 2 (high, *default*)\n"); + printf("\n"); } diff --git a/src/apps/bin/makeudfimage/Shell.h b/src/apps/bin/makeudfimage/Shell.h index 62d88885db..af638c7ab2 100644 --- a/src/apps/bin/makeudfimage/Shell.h +++ b/src/apps/bin/makeudfimage/Shell.h @@ -12,17 +12,21 @@ #define _SHELL_H #include +#include -#include "SupportDefs.h" +#include "ProgressListener.h" class Shell { public: Shell(); - void Run(int argc, char *argv[]); + status_t Run(int argc, char *argv[]); + private: status_t _ProcessArguments(int argc, char *argv[]); status_t _ProcessArgument(std::string arg, int argc, char *argv[]); void _PrintHelp(); + + VerbosityLevel fVerbosityLevel; };