Added basic verbosity support, and initial UdfBuilder creation and execution.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5466 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Tyler Dauwalder
2003-11-23 22:14:24 +00:00
parent 5e4cddfd9e
commit 2c8a6eec09
2 changed files with 40 additions and 10 deletions
+34 -8
View File
@@ -14,18 +14,28 @@
#include <stdio.h> #include <stdio.h>
#include "ConsoleListener.h"
#include "Debug.h" #include "Debug.h"
#include "UdfBuilder.h"
Shell::Shell() Shell::Shell()
: fVerbosityLevel(VERBOSITY_HIGH)
{ {
} }
void status_t
Shell::Run(int argc, char *argv[]) Shell::Run(int argc, char *argv[])
{ {
DEBUG_INIT("Shell"); DEBUG_INIT("Shell");
_ProcessArguments(argc, argv); status_t error = _ProcessArguments(argc, argv);
PRINT(("finished\n")); if (!error) {
ConsoleListener listener(fVerbosityLevel);
UdfBuilder builder(listener);
builder.Build();
} else {
_PrintHelp();
}
RETURN(error);
} }
status_t status_t
@@ -35,7 +45,7 @@ Shell::_ProcessArguments(int argc, char *argv[]) {
// If we're given no parameters, the default settings // If we're given no parameters, the default settings
// will do just fine // will do just fine
if (argc < 2) if (argc < 2)
return B_OK; RETURN(B_OK);
// Handle each command line argument (skipping the first // Handle each command line argument (skipping the first
// which is just the app name) // which is just the app name)
@@ -54,13 +64,29 @@ status_t
Shell::_ProcessArgument(std::string arg, int argc, char *argv[]) { Shell::_ProcessArgument(std::string arg, int argc, char *argv[]) {
DEBUG_INIT_ETC("Shell", ("arg: `%s'", arg.c_str())); DEBUG_INIT_ETC("Shell", ("arg: `%s'", arg.c_str()));
if (arg == "--help") { if (arg == "--help") {
_PrintHelp();
RETURN(B_ERROR); RETURN(B_ERROR);
} } else if (arg == "-v0") {
RETURN(B_ERROR); 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 void
Shell::_PrintHelp() { 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");
} }
+6 -2
View File
@@ -12,17 +12,21 @@
#define _SHELL_H #define _SHELL_H
#include <string> #include <string>
#include <SupportDefs.h>
#include "SupportDefs.h" #include "ProgressListener.h"
class Shell { class Shell {
public: public:
Shell(); Shell();
void Run(int argc, char *argv[]); status_t Run(int argc, char *argv[]);
private: private:
status_t _ProcessArguments(int argc, char *argv[]); status_t _ProcessArguments(int argc, char *argv[]);
status_t _ProcessArgument(std::string arg, int argc, char *argv[]); status_t _ProcessArgument(std::string arg, int argc, char *argv[]);
void _PrintHelp(); void _PrintHelp();
VerbosityLevel fVerbosityLevel;
}; };