Changeset 298
- Timestamp:
- 03/23/05 08:06:58 (4 years ago)
- Files:
-
- todo2/trunk/autogen.sh (modified) (2 diffs)
- todo2/trunk/doc (modified) (1 prop)
- todo2/trunk/src (modified) (1 prop)
- todo2/trunk/src/backend (modified) (1 prop)
- todo2/trunk/src/contactmethod (modified) (1 prop)
- todo2/trunk/src/filter (modified) (1 prop)
- todo2/trunk/src/filter/Expression.cc (modified) (2 diffs)
- todo2/trunk/src/filter/Expression.h (modified) (1 diff)
- todo2/trunk/src/Filter.h (modified) (1 diff)
- todo2/trunk/src/frontend (modified) (1 prop)
- todo2/trunk/src/FrontEnd.cc (modified) (1 diff)
- todo2/trunk/src/frontend/Console.cc (modified) (2 diffs)
- todo2/trunk/src/frontend/Console.h (modified) (2 diffs)
- todo2/trunk/src/FrontEnd.h (modified) (2 diffs)
- todo2/trunk/src/main.cc (modified) (10 diffs)
- todo2/trunk/src/Makefile.am (modified) (1 diff)
- todo2/trunk/src/Manager.cc (modified) (2 diffs)
- todo2/trunk/src/Module.cc (modified) (1 diff)
- todo2/trunk/src/Module.h (modified) (1 diff)
- todo2/trunk/src/PropertyMap.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
todo2/trunk/autogen.sh
r295 r298 1 1 #!/bin/sh 2 2 3 echo libtoolize 3 echo +aclocal 4 aclocal 5 echo +libtoolize 4 6 libtoolize --force --ltdl --automake --copy 5 7 #echo gettextize … … 7 9 #echo intltoolize 8 10 #intltoolize --force --copy 9 echo aclocal 10 aclocal 11 echo automake 11 echo +automake 12 12 automake --add-missing --copy 13 echo autoconf13 echo +autoconf 14 14 autoconf 15 echo autoheader15 echo +autoheader 16 16 autoheader 17 17 18 echo "Now you are ready to run ./configure" 18 echo 19 echo "Ready for ./configure to be run." todo2/trunk/doc
- Property svn:ignore changed from
Makefile.in
to
Makefile.in
Makefile
html
man
- Property svn:ignore changed from
todo2/trunk/src
- Property svn:ignore changed from
Makefile.in
to
Makefile.in
config.h
Makefile
todo2
stamp-h1
- Property svn:ignore changed from
todo2/trunk/src/backend
- Property svn:ignore changed from
Makefile.in
to
Makefile.in
Makefile
- Property svn:ignore changed from
todo2/trunk/src/contactmethod
- Property svn:ignore changed from
Makefile.in
to
Makefile.in
Makefile
- Property svn:ignore changed from
todo2/trunk/src/filter
- Property svn:ignore changed from
Makefile.in
to
Makefile.in
Makefile
- Property svn:ignore changed from
todo2/trunk/src/filter/Expression.cc
r297 r298 37 37 void Expression::args(crash::Args &args) { 38 38 args.add('f', "filter", Args::REQUIRED, _("Pass the database through a C-like filter expression. Use ? for help. In addition, any non-option arguments are treated directly as filter rules."), "<filter>"); 39 } 40 41 std::string Expression::help() { 42 return _( 43 "Filter expressions are similar to C or Perl expressions.\n" 44 "\n" 45 "There are four types of valid values; strings, numbers (floating point), words\n" 46 "and environment variables. Words are merely bare words such as foo or bar and\n" 47 "environment variables are words prefixed with a $.\n" 48 "\n" 49 " eg. $PATH || body\n" 50 "\n" 51 "Unary operators:\n" 52 "\n" 53 " !,not logical not\n" 54 "\n" 55 "Binary operators:\n" 56 "\n" 57 " ||,or logical or\n" 58 " &&,and logical and\n" 59 " ==,=,eq equal\n" 60 " !=,ne not equal\n" 61 " <,lt less than\n" 62 " >,gt greater than\n" 63 " <=,le less than or equal to\n" 64 " >=,ge greater than or equal to\n" 65 " >=,ge greater than or equal to\n" 66 " =~ regular expression equal to\n" 67 " !~ regular expression not equal to\n" 68 " + add the lhs and rhs\n" 69 " - subtract the rhs from the lhs\n" 70 " * multiply the lhs and rhs\n" 71 " / divide the lhs by the rhs\n" 72 "\n" 73 "Some standard values:\n" 74 "\n" 75 " title the title text (string)\n" 76 " body the body text (string)\n" 77 " priority the priority of the node (integer ranging from -2 to 3, with 0\n" 78 " being the default/medium priority)\n" 79 " completed whether this item is marked as complete\n" 80 " active whether this item is active (incomplete, and within its schedule\n" 81 " window)\n" 82 " children the number of children of the current node (integer)\n" 83 " index the numeric index of the current node (integer)\n" 84 " aindex the absolute index for the current node (string in the form\n" 85 " <n>.<m>.<o> ...)\n" 86 " depth the numeric depth of the current node (integer)\n" 87 " true boolean true\n" 88 " false boolean false\n" 89 " active is item active\n" 90 " created item creation time\n" 91 " modified item modification time\n" 92 " owner item owner\n" 93 " type item type\n" 94 " now current time\n" 95 " lifetime item lifetime\n" 96 " username current system username\n" 97 " hostname system hostname\n" 98 "\n" 99 "If a key is not present in the current node, it will be searched for under\n" 100 "the global configuration tree 'expression'.\n" 101 "\n" 102 " eg. The value 'stuff' will be retrieved from the current item, but if not\n" 103 " present, the global configuration key 'expression.stuff' will be tried.\n" 104 "\n" 105 "In addition, the expression filter also includes basic function support. Some\n" 106 "of these functions are:\n" 107 "\n" 108 " assigned(userid) true if the given userid is assigned to this item\n" 109 " size(key) the size of the specified key, in bytes\n" 110 " categorised(catid) true if this item is in the specified category\n" 111 " user(userid) true if the given user exists\n" 112 " category(catid) true if the specified category exists\n" 113 "\n" 114 "Examples:\n" 115 " priority > 2 && !completed\n" 116 " Display nodes with a priority greater than 2 that are incomplete.\n" 117 "\n" 118 " (priority > 1 && body =~ 'font.*large') || !completed\n" 119 " Display nodes with either a priority greater than 2 and the word 'font'\n" 120 " followed by 'large' in the body of the node, or nodes that are\n" 121 " incomplete.\n" 122 "\n" 123 "Last but not least, any unhandled arguments passed to " PACKAGE " are treated\n" 124 "as a filter expression.\n" 125 "\n" 126 " eg. $ " PACKAGE " not completed and now ge start and now le end\n" 127 ); 39 128 } 40 129 … … 51 140 if (arg.option() == 'f') { 52 141 if (arg.parameter() == "?") { 53 // TODO: use frontend->message(...) to display help? 54 manager.frontend()->message("filter:expression", _( 55 "Filter expressions are similar to C or Perl expressions.\n" 56 "\n" 57 "There are four types of valid values; strings, numbers (floating point), words\n" 58 "and environment variables. Words are merely bare words such as foo or bar and\n" 59 "environment variables are words prefixed with a $.\n" 60 "\n" 61 " eg. $PATH || body\n" 62 "\n" 63 "Unary operators:\n" 64 "\n" 65 " !,not logical not\n" 66 "\n" 67 "Binary operators:\n" 68 "\n" 69 " ||,or logical or\n" 70 " &&,and logical and\n" 71 " ==,=,eq equal\n" 72 " !=,ne not equal\n" 73 " <,lt less than\n" 74 " >,gt greater than\n" 75 " <=,le less than or equal to\n" 76 " >=,ge greater than or equal to\n" 77 " >=,ge greater than or equal to\n" 78 " =~ regular expression equal to\n" 79 " !~ regular expression not equal to\n" 80 " + add the lhs and rhs\n" 81 " - subtract the rhs from the lhs\n" 82 " * multiply the lhs and rhs\n" 83 " / divide the lhs by the rhs\n" 84 "\n" 85 "Some standard values:\n" 86 "\n" 87 " title the title text (string)\n" 88 " body the body text (string)\n" 89 " priority the priority of the node (integer ranging from -2 to 3, with 0\n" 90 " being the default/medium priority)\n" 91 " completed whether this item is marked as complete\n" 92 " active whether this item is active (incomplete, and within its schedule\n" 93 " window)\n" 94 " children the number of children of the current node (integer)\n" 95 " index the numeric index of the current node (integer)\n" 96 " aindex the absolute index for the current node (string in the form\n" 97 " <n>.<m>.<o> ...)\n" 98 " depth the numeric depth of the current node (integer)\n" 99 " true boolean true\n" 100 " false boolean false\n" 101 " active is item active\n" 102 " created item creation time\n" 103 " modified item modification time\n" 104 " owner item owner\n" 105 " type item type\n" 106 " now current time\n" 107 " lifetime item lifetime\n" 108 " username current system username\n" 109 " hostname system hostname\n" 110 "\n" 111 "If a key is not present in the current node, it will be searched for under\n" 112 "the global configuration tree 'expression'.\n" 113 "\n" 114 " eg. The value 'stuff' will be retrieved from the current item, but if not\n" 115 " present, the global configuration key 'expression.stuff' will be tried.\n" 116 "\n" 117 "In addition, the expression filter also includes basic function support. Some\n" 118 "of these functions are:\n" 119 "\n" 120 " assigned(userid) true if the given userid is assigned to this item\n" 121 " size(key) the size of the specified key, in bytes\n" 122 " categorised(catid) true if this item is in the specified category\n" 123 " user(userid) true if the given user exists\n" 124 " category(catid) true if the specified category exists\n" 125 "\n" 126 "Examples:\n" 127 " priority > 2 && !completed\n" 128 " Display nodes with a priority greater than 2 that are incomplete.\n" 129 "\n" 130 " (priority > 1 && body =~ 'font.*large') || !completed\n" 131 " Display nodes with either a priority greater than 2 and the word 'font'\n" 132 " followed by 'large' in the body of the node, or nodes that are\n" 133 " incomplete.\n" 134 "\n" 135 "Last but not least, any unhandled arguments passed to " PACKAGE " are treated\n" 136 "as a filter expression.\n" 137 "\n" 138 " eg. $ " PACKAGE " not completed and now ge start and now le end\n" 139 )); 142 manager.frontend()->message("filter:expression", help()); 140 143 exit(0); 141 144 } else todo2/trunk/src/filter/Expression.h
r295 r298 29 29 bool arg(crash::Args::iterator arg); 30 30 31 std::string help(); 32 31 33 private : 32 34 void applyFilter(Item *item, const crash::Expression::Node *expression) const; todo2/trunk/src/Filter.h
r295 r298 12 12 13 13 /** 14 A Filter transforms the 14 A Filter transforms the Database as it is loaded and saved. 15 16 For example, the Expression Filter matches each item against a C-like 17 expression and marks those that do not match as hidden. 18 19 Another filter might alter the contents on load and save, eg. encrypt and 20 decrypt. 15 21 */ 16 22 todo2/trunk/src/frontend
- Property svn:ignore changed from
Makefile.in
to
Makefile.in
Makefile
- Property svn:ignore changed from
todo2/trunk/src/FrontEnd.cc
r295 r298 16 16 } 17 17 18 void FrontEnd::remove (Item *item) {18 void FrontEnd::removed(Item *item) { 19 19 } 20 20 21 bool FrontEnd::insert(Item *item, Item::Index parent) { 22 } 23 24 Item *FrontEnd::edit(Item::Index index) { 21 bool FrontEnd::inserted(Item *item, Item::Index parent) { 22 return true; 25 23 } 26 24 todo2/trunk/src/frontend/Console.cc
r295 r298 46 46 47 47 void Console::args(crash::Args &args) { 48 ARG_COLOUR = args.add(Args::ALLOCATE, "colour", Args::OPTIONAL, _("When to use colour, defaults to always if not specified."), _("never|always|auto"));48 ARG_COLOUR = args.add(Args::ALLOCATE, "colour", Args::OPTIONAL, _("When to use colour, defaults to always if not specified."), "never|always|auto"); 49 49 ARG_COLOR = args.add(Args::ALLOCATE, "color", Args::OPTIONAL); 50 50 args.add('e', "edit", Args::REQUIRED, _("Edit the specified index."), _("<index>")); … … 123 123 } 124 124 125 Item *Console::edit(Item::Index item) { 126 return mdatabase->checkout(item); 127 } 128 129 void Console::commit(Item *item) { 130 mdatabase->commit(item); 131 } 132 133 void Console::discard(Item *item) { 134 mdatabase->discard(item); 135 } 136 125 137 void Console::present(Database *database) { 138 mdatabase = database; 126 139 throw Exception(this, "present() not implemented"); 127 140 } todo2/trunk/src/frontend/Console.h
r295 r298 22 22 void present(Database *database); 23 23 24 Item *edit(Item::Index item); 25 void commit(Item *item); 26 void discard(Item *item); 27 24 28 void message(std::string scope, std::string message); 25 29 void error(std::string scope, std::string message); … … 37 41 bool mtty, mcolour; 38 42 crash::Terminal mterm; 43 Database *mdatabase; 39 44 }; 40 45 todo2/trunk/src/FrontEnd.h
r295 r298 9 9 /** 10 10 The FrontEnd class abstracts the user interface to devtodo2. 11 12 All *user* access to the database should be performed through this 13 interface. 11 14 */ 12 15 … … 27 30 28 31 /// Inform the FrontEnd that the specified Item has been removed. 29 virtual void remove (Item *item);32 virtual void removed(Item *item); 30 33 /// Inform the FrontEnd that the specified Item has been inserted. 31 virtual bool insert (Item *item, Item::Index parent = "");34 virtual bool inserted(Item *item, Item::Index parent = ""); 32 35 33 /// Inform the FrontEnd that the specified Item is being edited. 34 virtual Item *edit(Item::Index index); 36 /** Inform the FrontEnd that the specified Item is being edited. Use 37 commit() and discard() to indicate completion. */ 38 virtual Item *edit(Item::Index index) = 0; 35 39 /// Commit changes done by a previous edit. 36 40 virtual void commit(Item *item); todo2/trunk/src/main.cc
r297 r298 42 42 Terminal terminal; 43 43 Args args; 44 enum { BACKENDS = -1000, FILTERS, FRONTENDS, HELP,SET, UNSET, DUMPCONFIG,44 enum { BACKENDS = -1000, FILTERS, FRONTENDS, SET, UNSET, DUMPCONFIG, 45 45 ARG_VERSION, LIST_MODULES, DATABASE, INFORM, DIE_ON_ERRORS, ADDRESS_BOOK, 46 46 PATH, CONTACTMETHODS }; 47 47 48 48 // specify default arguments 49 args.add( HELP, "help", Args::NONE, "Display this help.");50 args.add(BACKENDS, "backends", Args::REQUIRED, "Use specified backends.", "<backend>[,...]");51 args.add(FILTERS, "filters", Args::REQUIRED, "Use specified filters.", "<filter>[,...]");52 args.add(FRONTENDS, "frontends", Args::REQUIRED, "Use specified frontends.", "<frontend>[,...]");53 args.add(CONTACTMETHODS, "contact-methods", Args::REQUIRED, "Use specified contact methods.", "<method>[,...]");49 args.add('h', "help", Args::OPTIONAL, _("Display this help and optionally help on a specific module."), _("<module>")); 50 args.add(BACKENDS, "backends", Args::REQUIRED, _("Use specified backends."), _("<backend>[,...]")); 51 args.add(FILTERS, "filters", Args::REQUIRED, _("Use specified filters."), _("<filter>[,...]")); 52 args.add(FRONTENDS, "frontends", Args::REQUIRED, _("Use specified frontends."), _("<frontend>[,...]")); 53 args.add(CONTACTMETHODS, "contact-methods", Args::REQUIRED, _("Use specified contact methods."), _("<method>[,...]")); 54 54 args.add(SET, "set", Args::REQUIRED); 55 55 args.add(UNSET, "unset", Args::REQUIRED); 56 56 args.add(DUMPCONFIG, "dump-config", Args::NONE); 57 args.add(ARG_VERSION, "version", Args::NONE, "Display the version of devtodo2.");58 args.add(LIST_MODULES, "list-modules", Args::NONE, "Display list of active modules.");59 args.add(INFORM, "inform", Args::OPTIONAL, "Inform either the owners of modified items, or the comma seperated recipients listed, of any changes.", "<user>[,...]");60 args.add(DIE_ON_ERRORS, "die-on-errors", Args::NONE, "Abort on any error.");61 args.add(ADDRESS_BOOK, "address-book", Args::NONE, "Show entries in address book.");62 args.add('D', "debug", Args::REQUIRED, "Set debugging level.", "<level>");63 args.add(PATH, "path", Args::REQUIRED, "Specify database path to load (defaults to .todo2).", "<path>");57 args.add(ARG_VERSION, "version", Args::NONE, _("Display the version of devtodo2.")); 58 args.add(LIST_MODULES, "list-modules", Args::NONE, _("Display list of active modules.")); 59 args.add(INFORM, "inform", Args::OPTIONAL, _("Inform either the owners of modified items, or the comma seperated recipients listed, of any changes."), _("<user>[,...]")); 60 args.add(DIE_ON_ERRORS, "die-on-errors", Args::NONE, _("Abort on any error.")); 61 args.add(ADDRESS_BOOK, "address-book", Args::NONE, _("Show entries in address book.")); 62 args.add('D', "debug", Args::REQUIRED, _("Set debugging level."), _("<level>")); 63 args.add(PATH, "path", Args::REQUIRED, _("Specify database path to load (defaults to .todo2)."), _("<path>")); 64 64 65 65 /* Quick pass over arguments to check for debug settings */ … … 71 71 manager.set<int>("debug", debug_level); 72 72 } catch (BadCast) { 73 throw Exception("'" + i.parameter() + "' is an invalid debug level");73 throw Exception("'" + i.parameter() + _("' is an invalid debug level")); 74 74 } 75 75 break; 76 76 case SET : { 77 77 if (i.parameter().find('=') == string::npos) 78 throw Exception( "invalid config key/pair value '"+ i.parameter() + "'");78 throw Exception(_("invalid config key/pair value '") + i.parameter() + "'"); 79 79 const string 80 80 key = trim(i.parameter().substr(0, i.parameter().find('='))), … … 107 107 manager.set<int>("debug", debug_level); 108 108 } catch (BadCast) { 109 throw Exception("'" + i.parameter() + "' is an invalid debug level");109 throw Exception("'" + i.parameter() + _("' is an invalid debug level")); 110 110 } 111 111 break; … … 146 146 case SET : { 147 147 if (i.parameter().find('=') == string::npos) 148 throw Exception( "invalid config key/pair value '"+ i.parameter() + "'");148 throw Exception(_("invalid config key/pair value '") + i.parameter() + "'"); 149 149 const string 150 150 key = trim(i.parameter().substr(0, i.parameter().find('='))), … … 169 169 case SET : { 170 170 if (i.parameter().find('=') == string::npos) 171 throw Exception( "invalid config key/pair value '"+ i.parameter() + "'");171 throw Exception(_("invalid config key/pair value '") + i.parameter() + "'"); 172 172 const string 173 173 key = trim(i.parameter().substr(0, i.parameter().find('='))), … … 195 195 } 196 196 197 cout << "front-ends: "<< join(", ", fe) << endl;198 cout << "back-ends: "<< join(", ", be) << endl;199 cout << "filters: "<< join(", ", f) << endl;200 cout << "contactmethods: "<< join(", ", cc) << endl;197 cout << _("front-ends: ") << join(", ", fe) << endl; 198 cout << _("back-ends: ") << join(", ", be) << endl; 199 cout << _("filters: ") << join(", ", f) << endl; 200 cout << _("contactmethods: ") << join(", ", cc) << endl; 201 201 202 202 return 0; … … 209 209 return 0; 210 210 } break; 211 case HELP : 212 usage(terminal.columns(), args, argv[0]); 211 case 'h' : 212 if (i.hasParameter()) { 213 vector<Module*> modules = manager.moduleList(); 214 215 for (vector<Module*>::const_iterator j = modules.begin(); j != modules.end(); ++j) 216 if ((*j)->name() == i.parameter()) { 217 cout << (*j)->help() << endl; 218 return 0; 219 } 220 throw Exception(string(_("no such module ")) + "'" + i.parameter() + "'"); 221 } else 222 usage(terminal.columns(), args, argv[0]); 213 223 return 0; 214 224 break; … … 225 235 return manager.manage(args.begin(argc, argv), args.end()); 226 236 } catch (BadCast &e) { 227 cerr << manager.programName() << ": bad cast (typically caused by a call to crash::from_string<T>(s))"<< endl;237 cerr << manager.programName() << _(": bad cast (typically caused by a call to crash::from_string<T>(s))") << endl; 228 238 return 1; 229 239 } catch (BackEnd::Exception &e) { … … 243 253 return 2; 244 254 } catch (...) { 245 cerr << manager.programName() << ": fatal, unhandled exception"<< endl;255 cerr << manager.programName() << _(": fatal, unhandled exception") << endl; 246 256 return 3; 247 257 } … … 252 262 253 263 void usage(int width, Args &args, const char *self) { 254 cout << "usage: " << manager.programName() << " [<args>]"<< endl255 << "Where <args> can be any of the following:"<< endl;264 cout << _("usage: ") << manager.programName() << _(" [<args>]") << endl 265 << _("Where <args> can be any of the following:") << endl; 256 266 args.displayHelp(cout, width); 257 267 } todo2/trunk/src/Makefile.am
r297 r298 22 22 config.h 23 23 24 todo2_LDFLAGS=-export-dynamic @LIBLTDL@24 todo2_LDFLAGS=-export-dynamic $(QT_LIBS) todo2/trunk/src/Manager.cc
r297 r298 128 128 try { 129 129 BackEnd *backend = 0; 130 /* We need to attempt to make todo.database into an canonical path */ 130 131 /* We need to attempt to make todo.database into a canonical path */ 131 132 DEBUG(9, "canonicalising path '" << get("database")); 132 133 set("database", crash::realpath(get("database"))); … … 136 137 for (vector<BackEnd*>::iterator i = mbackends.begin(); i != mbackends.end(); ++i) { 137 138 DEBUG(4, "attempting load of " << get("database") << " with backend " << (*i)->name()); 138 if ((*i)-> loadable(get("database"))) {139 if ((*i)->usable() && (*i)->loadable(get("database"))) { 139 140 backend = *i; 140 141 DEBUG(1, "chose backend '" << backend->name() << "'"); todo2/trunk/src/Module.cc
r295 r298 19 19 return false; 20 20 } 21 22 std::string Module::help() { 23 return "No help available."; 24 } todo2/trunk/src/Module.h
r295 r298 45 45 /** Return true if the specified argument was handled by this object. */ 46 46 virtual bool arg(crash::Args::iterator argument); 47 /** Display help on this module. This is displayed if the user asks for 48 explicit help on a module. */ 49 std::string help(); 47 50 48 51 void name(std::string name) { mname = name; } todo2/trunk/src/PropertyMap.h
r297 r298 79 79 } 80 80 81 /// Return the value of a key, as a specific type. 81 /** Return the value of a key as a specific type. If the key does not 82 exist throw an Exception. */ 82 83 template <typename T> 83 84 const T get(std::string key) const { … … 92 93 } 93 94 94 /** Return the value of a key ,as a specific type. If the key does not95 exist ,return a default value. */95 /** Return the value of a key as a specific type. If the key does not 96 exist return a default value. */ 96 97 template <typename T> 97 98 const T get(std::string key, const T &def) const {
