Adding options parser more more intelligent version comming up

master
mickenordin 10 years ago
parent e5a78d201b
commit 6fecb16a87

File diff suppressed because it is too large Load Diff

@ -1 +1,318 @@
# dummy
src/main.o: src/main.cxx /usr/include/stdc-predef.h \
/usr/include/x86_64-linux-gnu/bits/predefs.h \
/usr/include/c++/4.8/iostream \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/os_defines.h \
/usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/cpu_defines.h \
/usr/include/c++/4.8/ostream /usr/include/c++/4.8/ios \
/usr/include/c++/4.8/iosfwd /usr/include/c++/4.8/bits/stringfwd.h \
/usr/include/c++/4.8/bits/memoryfwd.h \
/usr/include/c++/4.8/bits/postypes.h /usr/include/c++/4.8/cwchar \
/usr/include/wchar.h /usr/include/stdio.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h \
/usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/wchar2.h \
/usr/include/c++/4.8/exception \
/usr/include/c++/4.8/bits/atomic_lockfree_defines.h \
/usr/include/c++/4.8/bits/char_traits.h \
/usr/include/c++/4.8/bits/stl_algobase.h \
/usr/include/c++/4.8/bits/functexcept.h \
/usr/include/c++/4.8/bits/exception_defines.h \
/usr/include/c++/4.8/bits/cpp_type_traits.h \
/usr/include/c++/4.8/ext/type_traits.h \
/usr/include/c++/4.8/ext/numeric_traits.h \
/usr/include/c++/4.8/bits/stl_pair.h /usr/include/c++/4.8/bits/move.h \
/usr/include/c++/4.8/bits/concept_check.h \
/usr/include/c++/4.8/bits/stl_iterator_base_types.h \
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h \
/usr/include/c++/4.8/debug/debug.h \
/usr/include/c++/4.8/bits/stl_iterator.h \
/usr/include/c++/4.8/bits/localefwd.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++locale.h \
/usr/include/c++/4.8/clocale /usr/include/locale.h \
/usr/include/x86_64-linux-gnu/bits/locale.h /usr/include/c++/4.8/cctype \
/usr/include/ctype.h /usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
/usr/include/c++/4.8/bits/ios_base.h \
/usr/include/c++/4.8/ext/atomicity.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/gthr.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/gthr-default.h \
/usr/include/pthread.h /usr/include/sched.h /usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/timex.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/atomic_word.h \
/usr/include/c++/4.8/bits/locale_classes.h /usr/include/c++/4.8/string \
/usr/include/c++/4.8/bits/allocator.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++allocator.h \
/usr/include/c++/4.8/ext/new_allocator.h /usr/include/c++/4.8/new \
/usr/include/c++/4.8/bits/ostream_insert.h \
/usr/include/c++/4.8/bits/cxxabi_forced.h \
/usr/include/c++/4.8/bits/stl_function.h \
/usr/include/c++/4.8/backward/binders.h \
/usr/include/c++/4.8/bits/range_access.h \
/usr/include/c++/4.8/bits/basic_string.h \
/usr/include/c++/4.8/bits/basic_string.tcc \
/usr/include/c++/4.8/bits/locale_classes.tcc \
/usr/include/c++/4.8/streambuf /usr/include/c++/4.8/bits/streambuf.tcc \
/usr/include/c++/4.8/bits/basic_ios.h \
/usr/include/c++/4.8/bits/locale_facets.h /usr/include/c++/4.8/cwctype \
/usr/include/wctype.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/ctype_base.h \
/usr/include/c++/4.8/bits/streambuf_iterator.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/ctype_inline.h \
/usr/include/c++/4.8/bits/locale_facets.tcc \
/usr/include/c++/4.8/bits/basic_ios.tcc \
/usr/include/c++/4.8/bits/ostream.tcc /usr/include/c++/4.8/istream \
/usr/include/c++/4.8/bits/istream.tcc /usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \
/usr/include/x86_64-linux-gnu/bits/unistd.h src/begin.hpp \
/usr/include/c++/4.8/fstream /usr/include/c++/4.8/bits/codecvt.h \
/usr/include/c++/4.8/cstdio /usr/include/libio.h \
/usr/include/_G_config.h /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h \
/usr/include/x86_64-linux-gnu/bits/stdio2.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/basic_file.h \
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++io.h \
/usr/include/c++/4.8/bits/fstream.tcc
/usr/include/stdc-predef.h:
/usr/include/x86_64-linux-gnu/bits/predefs.h:
/usr/include/c++/4.8/iostream:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/os_defines.h:
/usr/include/features.h:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:
/usr/include/x86_64-linux-gnu/bits/wordsize.h:
/usr/include/x86_64-linux-gnu/gnu/stubs.h:
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/cpu_defines.h:
/usr/include/c++/4.8/ostream:
/usr/include/c++/4.8/ios:
/usr/include/c++/4.8/iosfwd:
/usr/include/c++/4.8/bits/stringfwd.h:
/usr/include/c++/4.8/bits/memoryfwd.h:
/usr/include/c++/4.8/bits/postypes.h:
/usr/include/c++/4.8/cwchar:
/usr/include/wchar.h:
/usr/include/stdio.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stdarg.h:
/usr/include/x86_64-linux-gnu/bits/wchar.h:
/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h:
/usr/include/xlocale.h:
/usr/include/x86_64-linux-gnu/bits/wchar2.h:
/usr/include/c++/4.8/exception:
/usr/include/c++/4.8/bits/atomic_lockfree_defines.h:
/usr/include/c++/4.8/bits/char_traits.h:
/usr/include/c++/4.8/bits/stl_algobase.h:
/usr/include/c++/4.8/bits/functexcept.h:
/usr/include/c++/4.8/bits/exception_defines.h:
/usr/include/c++/4.8/bits/cpp_type_traits.h:
/usr/include/c++/4.8/ext/type_traits.h:
/usr/include/c++/4.8/ext/numeric_traits.h:
/usr/include/c++/4.8/bits/stl_pair.h:
/usr/include/c++/4.8/bits/move.h:
/usr/include/c++/4.8/bits/concept_check.h:
/usr/include/c++/4.8/bits/stl_iterator_base_types.h:
/usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:
/usr/include/c++/4.8/debug/debug.h:
/usr/include/c++/4.8/bits/stl_iterator.h:
/usr/include/c++/4.8/bits/localefwd.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++locale.h:
/usr/include/c++/4.8/clocale:
/usr/include/locale.h:
/usr/include/x86_64-linux-gnu/bits/locale.h:
/usr/include/c++/4.8/cctype:
/usr/include/ctype.h:
/usr/include/x86_64-linux-gnu/bits/types.h:
/usr/include/x86_64-linux-gnu/bits/typesizes.h:
/usr/include/endian.h:
/usr/include/x86_64-linux-gnu/bits/endian.h:
/usr/include/x86_64-linux-gnu/bits/byteswap.h:
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h:
/usr/include/c++/4.8/bits/ios_base.h:
/usr/include/c++/4.8/ext/atomicity.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/gthr.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/gthr-default.h:
/usr/include/pthread.h:
/usr/include/sched.h:
/usr/include/time.h:
/usr/include/x86_64-linux-gnu/bits/sched.h:
/usr/include/x86_64-linux-gnu/bits/time.h:
/usr/include/x86_64-linux-gnu/bits/timex.h:
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:
/usr/include/x86_64-linux-gnu/bits/setjmp.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/atomic_word.h:
/usr/include/c++/4.8/bits/locale_classes.h:
/usr/include/c++/4.8/string:
/usr/include/c++/4.8/bits/allocator.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++allocator.h:
/usr/include/c++/4.8/ext/new_allocator.h:
/usr/include/c++/4.8/new:
/usr/include/c++/4.8/bits/ostream_insert.h:
/usr/include/c++/4.8/bits/cxxabi_forced.h:
/usr/include/c++/4.8/bits/stl_function.h:
/usr/include/c++/4.8/backward/binders.h:
/usr/include/c++/4.8/bits/range_access.h:
/usr/include/c++/4.8/bits/basic_string.h:
/usr/include/c++/4.8/bits/basic_string.tcc:
/usr/include/c++/4.8/bits/locale_classes.tcc:
/usr/include/c++/4.8/streambuf:
/usr/include/c++/4.8/bits/streambuf.tcc:
/usr/include/c++/4.8/bits/basic_ios.h:
/usr/include/c++/4.8/bits/locale_facets.h:
/usr/include/c++/4.8/cwctype:
/usr/include/wctype.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/ctype_base.h:
/usr/include/c++/4.8/bits/streambuf_iterator.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/ctype_inline.h:
/usr/include/c++/4.8/bits/locale_facets.tcc:
/usr/include/c++/4.8/bits/basic_ios.tcc:
/usr/include/c++/4.8/bits/ostream.tcc:
/usr/include/c++/4.8/istream:
/usr/include/c++/4.8/bits/istream.tcc:
/usr/include/unistd.h:
/usr/include/x86_64-linux-gnu/bits/posix_opt.h:
/usr/include/x86_64-linux-gnu/bits/environments.h:
/usr/include/x86_64-linux-gnu/bits/confname.h:
/usr/include/getopt.h:
/usr/include/x86_64-linux-gnu/bits/unistd.h:
src/begin.hpp:
/usr/include/c++/4.8/fstream:
/usr/include/c++/4.8/bits/codecvt.h:
/usr/include/c++/4.8/cstdio:
/usr/include/libio.h:
/usr/include/_G_config.h:
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h:
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h:
/usr/include/x86_64-linux-gnu/bits/stdio.h:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/basic_file.h:
/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++io.h:
/usr/include/c++/4.8/bits/fstream.tcc:

@ -22,11 +22,38 @@
#include <iostream>
#include <string>
#include <unistd.h>
#include "begin.hpp"
using namespace std;
int main(int argc, char **argv)
{
int main(int argc, char **argv) {
int c;
string usage = "Usage: begin [-z|-j] <regex> [filename] \n";
bool gzip = false;
bool bzip2 = false;
while((c = getopt(argc, argv, "jhz?")) != EOF) {
switch (c) {
case 'j':
bzip2 = true;
break;
case 'h':
cout << usage;
return 1;
case 'z':
gzip = true;
break;
case '?':
cout << usage;
return 1;
}
}
if(gzip and bzip2) {
cerr << "Please choose only one compression method\n";
return 1;
}
int works = 1; //default return value
if( argc == 2) { //assume the argument is a regex and to read from std in
@ -34,8 +61,12 @@ int main(int argc, char **argv)
} else if( argc == 3) { //assume the first argument is a regex and second is a filename
ifstream in(argv[2]);
works = begin(argv[1], in); //try the search
} else if(gzip) { // gzip flag is set so we will try to decompress and try the search
cout << "Decompressing\n";
} else if(bzip2){ // bzip2 flag is set so we will try to decompress and try the search
cout << "Decompressing\n";
} else { //Wrong number of command line args
cout << "Usage: begin <regex> [filename] \n";
cout << usage;
}
return works;

Loading…
Cancel
Save