//////////////////////////////////////////////////////////////////////////////// // // Copyright 2015 - 2018, Paul Beckingham, Federico Hernandez. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // // https://www.opensource.org/licenses/mit-license.php // //////////////////////////////////////////////////////////////////////////////// #include #include #include //////////////////////////////////////////////////////////////////////////////// int CmdHelpUsage (const Extensions& extensions) { // TODO This is going to need more formatting. // TODO Align the arg types? std::cout << '\n' << "Usage: timew [--version]\n" << " timew cancel\n" << " timew config [ [] [|]\n" << " timew day [] [ ...]\n" << " timew delete @ [@ ...]\n" << " timew diagnostics\n" << " timew export [] [ ...]\n" << " timew extensions\n" /* << " timew fill @ [@ ...]\n" */ << " timew gaps [] [ ...]\n" << " timew get [ ...]\n" << " timew help [ | interval | hints | date | duration]\n" << " timew join @ @\n" << " timew lengthen @ [@ ...] \n" << " timew month [] [ ...]\n" << " timew move @ \n" << " timew [report] [] [ ...]\n" << " timew shorten @ [@ ...] \n" << " timew show\n" << " timew split @ [@ ...]\n" << " timew start [] [ ...]\n" << " timew stop [ ...]\n" << " timew summary [] [ ...]\n" << " timew tag @ [@ ...] [ ...]\n" << " timew tags [] [ ...]\n" << " timew track [ ...]\n" << " timew untag @ [@ ...] [ ...]\n" << " timew week [] [ ...]\n" << '\n'; if (!extensions.all ().empty ()) { std::cout << "Extensions (extensions do not provide help):\n"; for (auto& ext : extensions.all ()) std::cout << " " << File (ext).name () << '\n'; std::cout << '\n'; } std::cout << "Additional help:\n" << " timew help \n" << " timew help interval\n" << " timew help hints\n" << " timew help date\n" << " timew help duration\n" << " timew help dom\n" << '\n' << "Interval:\n" << " [from] \n" << " [from] to/- \n" << " [from] for \n" << " before/after \n" << " ago\n" << " [for] \n" << '\n' << "Tag:\n" << " Word\n" << " 'Single Quoted Words'\n" << " \"Double Quoted Words\"\n" << " Escaped\\ Spaces\n" << '\n' << "Configuration overrides:\n" << " rc.=\n" << '\n'; // TODO List all extensions. return 0; } //////////////////////////////////////////////////////////////////////////////// // TODO Should the CmdXxx functions themselves be responsible for providing both // the command syntax and the help text? // A: Only if they are upgraded to objects. // // Strict 80-character limit. // Provide examples where appropriate - enough to cover all uses. int CmdHelp ( const CLI& cli, const Extensions& extensions) { auto words = cli.getWords (); if (! words.empty ()) { // Ruler 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 if (words[0] == "cancel") std::cout << '\n' << "Syntax: timew cancel\n" << '\n' << "If there is an open interval, it is abandoned.\n" << '\n' << "See also 'start', 'stop', 'delete'.\n" << '\n'; // Ruler 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 else if (words[0] == "config") std::cout << '\n' << "Syntax: timew config [ [ | '']]\n" << '\n' << "Allows setting and removing configuration values, as an alternative to directly\n" << "editing your ~/.timewarrior/timewarrior.cfg file. For example:\n" << '\n' << " $ timew config verbose yes\n" << " $ timew config verbose ''\n" << " $ timew config verbose\n" << '\n' << "The first command sets 'verbose' to 'yes'. The second sets it to a blank value\n" << "which overrides the default value. The third example deletes the 'verbose'\n" << "setting.\n" << '\n' << "When modifying configuration in this way, interactive confirmation will be\n" << "sought. To override this confirmation, use the ':yes' hint, which means you\n" << "intend to answer 'yes' to the confirmation questions:\n" << '\n' << " $ timew config verbose '' :yes\n" << '\n' << "If no arguments are provided, all configuration settings are shown:\n" << '\n' << " $ timew config\n" << " verbose = yes\n" << " ...\n" << '\n' << "See also 'hints', 'show'.\n" << '\n'; // Ruler 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 else if (words[0] == "continue") std::cout << '\n' << "Syntax: timew continue [] [|]\n" << '\n' << "Resumes tracking of a closed interval. For example:\n" << '\n' << " $ timew track 9am - 10am tag1 tag2\n" << " $ timew continue\n" << '\n' << "This continues the most recent interval. One can refer to another closed\n" << "interval by referencing its id:\n" << '\n' << " $ timew track 9am - 10am tag1 tag2\n" << " $ timew track 11am - 1pm tag3\n" << " $ timew continue @2\n" << '\n' << "The 'continue' command creates a new interval, starting now, and using the tags\n" << "'tag1' and 'tag2'. (Using the 'summary' command and specifying the ':ids' hint\n" << "shows interval IDs.) Independently from an ID, one can specify a new start time\n" << "or an interval range:\n" << '\n' << " $ timew continue @2 4min ago\n" << '\n' << "This continues the interval referenced by ID 2 with a new start time (4 minutes\n" << "before now)\n" << '\n' << " $ timew continue 18pm - 19pm\n" << '\n' << "This adds a copy of the latest interval with a new interval range.\n" << '\n' << "'continue' is a convenient way to resume work without re-entering the tags.\n" << '\n' << "See also 'start', 'stop'.\n" << '\n'; // Ruler 1 2 3 4 5 6 7 8 // 12345678901234567890123456789012345678901234567890123456789012345678901234567890 else if (words[0] == "date") std::cout << '\n' << "Timewarrior supports the following date formats based on ISO-8601:\n" << '\n' << " [T ] Extended date, optional extended time\n" << " [T