diff options
author | Alexis211 <alexis211@gmail.com> | 2009-12-20 15:21:26 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-12-20 15:21:26 +0100 |
commit | cab353cbb21c142ac1e227d42338fa587e1a7f24 (patch) | |
tree | 618c50ba58cc3186b3b82a3df2561063d4aaee85 /Source/Library/Userland/App | |
parent | 07a73aea7acbf0d9f9182bc3557583aa17af0000 (diff) | |
download | Melon-cab353cbb21c142ac1e227d42338fa587e1a7f24.tar.gz Melon-cab353cbb21c142ac1e227d42338fa587e1a7f24.zip |
Worked on IStream. Seems to work
Diffstat (limited to 'Source/Library/Userland/App')
-rw-r--r-- | Source/Library/Userland/App/ShellApp.proto.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Source/Library/Userland/App/ShellApp.proto.cpp b/Source/Library/Userland/App/ShellApp.proto.cpp index a3d9737..f2233bc 100644 --- a/Source/Library/Userland/App/ShellApp.proto.cpp +++ b/Source/Library/Userland/App/ShellApp.proto.cpp @@ -14,6 +14,7 @@ void ShellApp::init() { u32int argc = pr.argc(); for (u32int i = 0; i < argc; i++) { String arg = pr.argv(i); + if (arg.empty()) continue; if (arg == "-") { i++; if (i == argc) { @@ -26,13 +27,13 @@ void ShellApp::init() { bool found = false; for (u32int i = 0; i < flags.size(); i++) { if (flags[i].type == FT_BOOL) { - if (arg == String("--no-") + flags[i].lName) { + if (arg == (String("--no-") += flags[i].lName)) { flags[i].boolVal = false; found = true; } } } - if (!found) outvt << "Unknown option : " << arg << "\n"; + if (!found) outvt << "Unknown option : " << arg << ENDL; } else if (arg.substr(0, 2) == "--") { bool found = false; for (u32int i = 0; i < flags.size(); i++) { @@ -49,21 +50,29 @@ void ShellApp::init() { } } } - if (!found) outvt << "Unknown option : " << arg << "\n"; + if (!found) outvt << "Unknown option : " << arg << ENDL; } else { for (u32int j = 1; j < arg.size(); j++) { bool found = false; for (u32int k = 0; k < flags.size(); k++) { if (flags[k].sName == arg[j]) { found = true; - if (flags[k].type == FT_BOOL) flags[k].boolVal = true; - if (flags[k].type == FT_INT) flags[k].intVal = pr.argv(++i).toInt(); - if (flags[k].type == FT_STR) flags[k].strVal = pr.argv(++i); + if (flags[k].type == FT_BOOL) { + flags[k].boolVal = true; + } else { + i++; + if (i >= argc) { + outvt << "Missing argument for flag : -" << String(arg[j], 1) << ENDL; + } else { + flags[k].strVal = pr.argv(i); + if (flags[k].type == FT_INT) flags[k].intVal = flags[k].strVal.toInt(); + } + } break; } } if (!found) { - outvt << "Unknown option : -" << String(arg[j]) << "\n"; + outvt << "Unknown option : -" << String(arg[j], 1) << ENDL; exit(-1); } } |