diff --git a/src/main.cc b/src/main.cc
index f3cbafd..8892e1e 100644
|
a
|
b
|
|
| 2 | 2 | #include "support.h" |
| 3 | 3 | #include "config.h" |
| 4 | 4 | #include "todorl.h" |
| | 5 | #include "stdio.h" |
| | 6 | #include "unistd.h" |
| 5 | 7 | |
| 6 | 8 | void joinArgs(TodoDB &todo, vector<string> const &args, int argc, char const **argv) { |
| 7 | 9 | char const *av[args.size() + argc]; |
| … |
… |
|
| 40 | 42 | if (options.verbose > 1) |
| 41 | 43 | cout << "todo: switched to global database '" << database << "'" << endl; |
| 42 | 44 | } |
| 43 | | if (options.verbose > 1) |
| 44 | | cout << "todo: attempting load of '" << database << "'" << endl; |
| 45 | | todo.load(database); |
| | 45 | // Switch to recursive database |
| | 46 | else if (options.pathrecursive) { |
| | 47 | // Grab current location |
| | 48 | char cur_path[FILENAME_MAX]; |
| | 49 | getcwd(cur_path, sizeof(cur_path)); |
| | 50 | |
| | 51 | string local_path = cur_path; |
| | 52 | |
| | 53 | // Flag for match in todo file |
| | 54 | int invalid_todo = 1; |
| | 55 | while (invalid_todo) { |
| | 56 | database = local_path + "/" + options.database; |
| | 57 | // Check if .todo exists in the local folder |
| | 58 | FILE* fp = fopen(database.c_str(), "r"); |
| | 59 | if (fp) { |
| | 60 | invalid_todo = 0; |
| | 61 | } else { |
| | 62 | if (options.verbose > 1) |
| | 63 | cout << "todo: no database found in path " << database << " , continuing" << endl; |
| | 64 | // file doesn't exist or is unreadable |
| | 65 | // remove the last folder and keep searching |
| | 66 | size_t match; |
| | 67 | match = local_path.rfind('/'); |
| | 68 | |
| | 69 | if (local_path.length()) { |
| | 70 | local_path.erase(match); |
| | 71 | } else { |
| | 72 | // Abort the while cycle if we have no match |
| | 73 | // or reached the root the second time |
| | 74 | break; |
| | 75 | } |
| | 76 | } |
| | 77 | } |
| | 78 | } |
| | 79 | |
| | 80 | if (options.verbose > 1) |
| | 81 | cout << "todo: attempting load of '" << database << "'" << endl; |
| | 82 | todo.load(database); |
| | 83 | |
| 46 | 84 | } catch (TodoDB::quit &e) { |
| 47 | 85 | // Quit is thrown if the .todo file can't be accessed |
| 48 | 86 | if (options.verbose > 1) |
diff --git a/src/support.cc b/src/support.cc
index c7b4037..62be4ee 100644
|
a
|
b
|
|
| 19 | 19 | |
| 20 | 20 | Options::Options() : |
| 21 | 21 | verbose(0), purgeage(0), mono(false), paranoid(false), global(false), |
| 22 | | summary(false), timeout(false), comment(false), |
| | 22 | pathrecursive(false), summary(false), timeout(false), comment(false), |
| 23 | 23 | database(".todo"), |
| 24 | 24 | priority(Todo::None), |
| 25 | 25 | mode(TodoDB::View), |
| … |
… |
|
| 224 | 224 | args.setHelp('D', "Mark the specified notes (and all children) as not done."); |
| 225 | 225 | args.addArgument(GlobalDatabase, "global-database", CommandArgs::Required); |
| 226 | 226 | args.setHelp(GlobalDatabase, "Specify the database to use if the -G (--global) parameter is used."); |
| | 227 | args.addArgument('P', "path-recursive"); |
| | 228 | args.setHelp('P', "Navigate the recursively the parent folders searching for a todo database."); |
| 227 | 229 | args.addArgument('G', "global"); |
| 228 | 230 | args.setHelp('G', "Use the database specified by the --global-database option. Defaults to ~/.todo_global."); |
| 229 | 231 | args.addArgument(Database, "database", CommandArgs::Required); |
| … |
… |
|
| 352 | 354 | case 's' : |
| 353 | 355 | options.summary = !options.summary; |
| 354 | 356 | break; |
| | 357 | case 'P' : |
| | 358 | options.pathrecursive = true; |
| | 359 | break; |
| 355 | 360 | case 'G' : |
| 356 | 361 | options.global = true; |
| 357 | 362 | break; |
| … |
… |
|
| 769 | 774 | static bool rcvalid(string const &str) { |
| 770 | 775 | return str == "verbose" || str == "filter" || str == "priority" || |
| 771 | 776 | str == "TODO" || str == "colour" || str == "mono" || |
| 772 | | str == "global-database" || str == "global" || |
| | 777 | str == "global-database" || str == "global" || str == "path-recursive" || |
| 773 | 778 | str == "database" || str == "date-format" || |
| 774 | 779 | str == "sort" || str == "display-format" || |
| 775 | 780 | str == "generated-format" || str == "verbose-display-format" || |
diff --git a/src/support.h b/src/support.h
index adadbda..bab6118 100644
|
a
|
b
|
|
| 16 | 16 | enum Dir { Negative = -1, Equal = 0, Positive = +1 }; |
| 17 | 17 | |
| 18 | 18 | int verbose, purgeage; |
| 19 | | bool mono, paranoid, global, summary, timeout, comment; |
| | 19 | bool mono, paranoid, global, pathrecursive, summary, timeout, comment; |
| 20 | 20 | string text, database, globaldatabase, filename, |
| 21 | 21 | dateformat; |
| 22 | 22 | map<string, string> format; |
diff --git a/src/todoterm.cc b/src/todoterm.cc
index a979d1b..40aa030 100644
|
a
|
b
|
|
| 2 | 2 | #include "todoterm.h" |
| 3 | 3 | |
| 4 | 4 | #ifdef USETERMCAP |
| | 5 | #include <cstdlib> |
| 5 | 6 | #include <iostream> |
| 6 | 7 | #include <string> |
| 7 | 8 | #include <stdexcept> |