• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

GothenburgBitFactory / taskwarrior / 11804681203

12 Nov 2024 07:52PM UTC coverage: 85.496% (-0.03%) from 85.524%
11804681203

push

github

web-flow
Release v3.2.0 (#3679)

0 of 5 new or added lines in 1 file covered. (0.0%)

3 existing lines in 2 files now uncovered.

19157 of 22407 relevant lines covered (85.5%)

22973.87 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.88
/src/commands/CmdNews.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included
13
// in all copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
//
23
// https://www.opensource.org/licenses/mit-license.php
24
//
25
////////////////////////////////////////////////////////////////////////////////
26

27
#include <cmake.h>
28
// cmake.h include header must come first
29

30
#include <CmdNews.h>
31
#include <Context.h>
32
#include <Datetime.h>
33
#include <Duration.h>
34
#include <Table.h>
35
#include <format.h>
36
#include <main.h>
37
#include <shared.h>
38
#include <util.h>
39

40
#include <cmath>
41
#include <csignal>
42
#include <iostream>
43

44
/* Adding a new version:
45
 *
46
 * - Add a new `versionX_Y_Z` method to `NewsItem`, and add news items for the new
47
 *   release.
48
 * - Call the new method in `NewsItem.all()`. Calls should be in version order.
49
 * - Test with `task news`.
50
 */
51

52
////////////////////////////////////////////////////////////////////////////////
53
CmdNews::CmdNews() {
4,495✔
54
  _keyword = "news";
4,495✔
55
  _usage = "task          news";
4,495✔
56
  _description = "Displays news about the recent releases";
4,495✔
57
  _read_only = true;
4,495✔
58
  _displays_id = false;
4,495✔
59
  _needs_gc = false;
4,495✔
60
  _uses_context = false;
4,495✔
61
  _accepts_filter = false;
4,495✔
62
  _accepts_modifications = false;
4,495✔
63
  _accepts_miscellaneous = false;
4,495✔
64
  _category = Command::Category::misc;
4,495✔
65
}
4,495✔
66

67
////////////////////////////////////////////////////////////////////////////////
68
static void signal_handler(int s) {
×
69
  if (s == SIGINT) {
×
70
    Color footnote;
×
71
    if (Context::getContext().color()) {
×
72
      if (Context::getContext().config.has("color.footnote"))
×
73
        footnote = Color(Context::getContext().config.get("color.footnote"));
×
74
    }
75

76
    std::cout << "\n\nCome back and read about new features later!\n";
×
77

78
    std::cout << footnote.colorize(
×
79
        "\nIf you enjoy Taskwarrior, please consider supporting the project at:\n"
80
        "    https://github.com/sponsors/GothenburgBitFactory/\n");
×
81
    exit(1);
×
82
  }
83
}
84

85
void wait_for_enter() {
×
86
  signal(SIGINT, signal_handler);
×
87

88
  std::string dummy;
×
89
  std::cout << "\nPress enter to continue..";
×
90
  std::getline(std::cin, dummy);
×
91
  std::cout << "\33[2K\033[A\33[2K";  // Erase current line, move up, and erase again
×
92

93
  signal(SIGINT, SIG_DFL);
×
94
}
95

96
////////////////////////////////////////////////////////////////////////////////
97
// Holds information about single improvement / bug.
98
//
99
NewsItem::NewsItem(Version version, const std::string& title, const std::string& bg_title,
×
100
                   const std::string& background, const std::string& punchline,
101
                   const std::string& update, const std::string& reasoning,
102
                   const std::string& actions) {
×
103
  _version = version;
×
104
  _title = title;
×
105
  _bg_title = bg_title;
×
106
  _background = background;
×
107
  _punchline = punchline;
×
108
  _update = update;
×
109
  _reasoning = reasoning;
×
110
  _actions = actions;
×
111
}
112

113
void NewsItem::render() {
×
114
  auto config = Context::getContext().config;
×
115
  Color header;
×
116
  Color footnote;
×
117
  Color bold;
×
118
  Color underline;
×
119
  if (Context::getContext().color()) {
×
120
    bold = Color("bold");
×
121
    underline = Color("underline");
×
122
    if (config.has("color.header")) header = Color(config.get("color.header"));
×
123
    if (config.has("color.footnote")) footnote = Color(config.get("color.footnote"));
×
124
  }
125

126
  // TODO: For some reason, bold cannot be blended in 256-color terminals
127
  // Apply this workaround of colorizing twice.
128
  std::cout << bold.colorize(header.colorize(format("{1} ({2})\n", _title, _version)));
×
129
  if (_background.size()) {
×
130
    if (_bg_title.empty()) _bg_title = "Background";
×
131

132
    std::cout << "\n  " << underline.colorize(_bg_title) << std::endl << _background << std::endl;
×
133
  }
134

135
  wait_for_enter();
×
136

137
  std::cout << "  " << underline.colorize(format("What changed in {1}?\n", _version));
×
138
  if (_punchline.size()) std::cout << footnote.colorize(format("{1}\n", _punchline));
×
139

140
  if (_update.size()) std::cout << format("{1}\n", _update);
×
141

142
  wait_for_enter();
×
143

144
  if (_reasoning.size()) {
×
145
    std::cout << "  " << underline.colorize("What was the motivation behind this feature?\n")
×
146
              << _reasoning << std::endl;
×
147
    wait_for_enter();
×
148
  }
149

150
  if (_actions.size()) {
×
151
    std::cout << "  " << underline.colorize("What do I have to do?\n") << _actions << std::endl;
×
152
    wait_for_enter();
×
153
  }
154
}
155

156
std::vector<NewsItem> NewsItem::all() {
×
157
  std::vector<NewsItem> items;
×
158
  version2_6_0(items);
×
159
  version3_0_0(items);
×
160
  version3_1_0(items);
×
NEW
161
  version3_2_0(items);
×
UNCOV
162
  return items;
×
163
}
164

165
////////////////////////////////////////////////////////////////////////////////
166
// Generate the highlights for the 2.6.0 version.
167
//
168
// - XDG directory mode (high)
169
// - Support for Unicode 11 characters (high)
170
// - 64 bit values, UDAs, Datetime values until year 9999 (high)
171
// - Config context variables
172
// - Reports outside of context
173
// - Environment variables in taskrc (high)
174
// - Waiting is a virtual concept (high)
175
// - Improved parser and task display mechanism
176
// - The .by attribute modifier
177
// - Exporting a report
178
// - Multi-day holidays
179
void NewsItem::version2_6_0(std::vector<NewsItem>& items) {
×
180
  Version version("2.6.0");
×
181
  /////////////////////////////////////////////////////////////////////////////
182
  // - Writeable context
183

184
  // Detect whether user uses any contexts
185
  auto config = Context::getContext().config;
×
186
  std::stringstream advice;
×
187

188
  auto defined = CmdContext::getContexts();
×
189
  if (defined.size()) {
×
190
    // Detect the old-style contexts
191
    std::vector<std::string> old_style;
×
192
    std::copy_if(defined.begin(), defined.end(), std::back_inserter(old_style),
×
193
                 [&](auto& name) { return config.has("context." + name); });
×
194

195
    if (old_style.size()) {
×
196
      advice << format("  You have {1} defined contexts, out of which {2} are old-style:\n",
×
197
                       defined.size(),
198
                       std::count_if(defined.begin(), defined.end(),
199
                                     [&](auto& name) { return config.has("context." + name); }));
×
200

201
      for (auto context : defined) {
×
202
        std::string old_definition = config.get("context." + context);
×
203
        if (old_definition != "") advice << format("  * {1}: {2}\n", context, old_definition);
×
204
      }
205

206
      advice << "\n"
207
                "  These need to be migrated to new-style, which uses context.<name>.read and\n"
208
                "  context.<name>.write config variables. Please run the following commands:\n";
×
209

210
      for (auto context : defined) {
×
211
        std::string old_definition = config.get("context." + context);
×
212
        if (old_definition != "")
×
213
          advice << format("  $ task context define {1} '{2}'\n", context, old_definition);
×
214
      }
215

216
      advice
217
          << "\n"
218
             "  Please check these filters are also valid modifications. If a context filter is "
219
             "not\n"
220
             "  a valid modification, you can set the context.<name>.write configuration variable "
221
             "to\n"
222
             "  specify the write context explicitly. Read more in CONTEXT section of man taskrc.";
×
223
    } else
224
      advice << "  You don't have any old-style contexts defined, so you're good to go as is!";
×
225
  } else
×
226
    advice << "  You don't have any contexts defined, so you're good to go as is!\n"
227
              "  Read more about how to use contexts in CONTEXT section of 'man task'.";
×
228

229
  NewsItem writeable_context(
230
      version, "'Writeable' context", "Background - what is context?",
231
      "  The 'context' is a feature (introduced in 2.5.0) that allows users to apply a\n"
232
      "  predefined filter to all task reports.\n"
233
      "  \n"
234
      "    $ task context define work \"project:Work or +urgent\"\n"
235
      "    $ task context work\n"
236
      "    Context 'work' set. Use 'task context none' to remove.\n"
237
      "  \n"
238
      "  Now if we proceed to add two tasks:\n"
239
      "    $ task add Talk to Jeff pro:Work\n"
240
      "    $ task add Call mom pro:Personal\n"
241
      "  \n"
242
      "    $ task\n"
243
      "    ID Age   Project Description  Urg\n"
244
      "     1 16s   Work    Talk to Jeff    1\n"
245
      "  \n"
246
      "  The task \"Call mom\" will not be listed, because it does not match\n"
247
      "  the active context (its project is 'Personal' and not 'Work').",
248
      "  The currently active context definition is now applied as default modifications\n"
249
      "  when creating new tasks using 'task add' and 'task log'.",
250
      "  \n"
251
      "  Consider following example, using context 'work' defined as 'project:Work' above:\n"
252
      "  \n"
253
      "    $ task context work\n"
254
      "    $ task add Talk to Jeff\n"
255
      "    $ task\n"
256
      "    ID Age  Project Description  Urg \n"
257
      "     1 1s   Work    Talk to Jeff    1\n"
258
      "            ^^^^^^^\n"
259
      "  \n"
260
      "  Note that project attribute was set to 'Work' automatically.",
261
      "  This was a popular feature request. Now, if you have a context active,\n"
262
      "  newly added tasks no longer \"fall outside\" of the context by default.",
263
      advice.str());
×
264
  items.push_back(writeable_context);
×
265

266
  /////////////////////////////////////////////////////////////////////////////
267
  // - 64-bit datetime support
268

269
  NewsItem uint64_support(
270
      version, "Support for 64-bit timestamps and numeric values", "", "",
271
      "  Taskwarrior now supports 64-bit timestamps, making it possible to set due dates\n"
272
      "  and other date attributes beyond 19 January 2038 (limit of 32-bit timestamps).\n",
273
      "  The current limit is 31 December 9999 for display reasons (last 4-digit year).",
274
      "  With each year passing by faster than the last, setting tasks for 2040s\n"
275
      "  is not as unfeasible as it once was.",
276
      "  Don't forget that 50-year anniversary and 'task add' a long-term task today!");
×
277
  items.push_back(uint64_support);
×
278

279
  /////////////////////////////////////////////////////////////////////////////
280
  // - Waiting is a virtual status
281

282
  NewsItem waiting_status(
283
      version, "Deprecation of the status:waiting", "",
284
      "  If a task has a 'wait' attribute set to a date in the future, it is modified\n"
285
      "  to have a 'waiting' status. Once that date is no longer in the future, the status\n"
286
      "  is modified to back to 'pending'.",
287
      "  The 'waiting' value of status is deprecated, instead users should use +WAITING\n"
288
      "  virtual tag, or explicitly query for wait.after:now (the two are equivalent).",
289
      "  \n"
290
      "  The status:waiting query still works in 2.6.0, but support will be dropped in 3.0.",
291
      "",
292
      "  In your custom report definitions, the following expressions should be replaced:\n"
293
      "  * 'status:pending or status:waiting' should be replaced by 'status:pending'\n"
294
      "  * 'status:pending' should be replaced by 'status:pending -WAITING'");
×
295
  items.push_back(waiting_status);
×
296

297
  /////////////////////////////////////////////////////////////////////////////
298
  // - Support for environment variables in the taskrc
299

300
  NewsItem env_vars(
301
      version, "Environment variables in the taskrc", "", "",
302
      "  Taskwarrior now supports expanding environment variables in the taskrc file,\n"
303
      "  allowing users to customize the behaviour of 'task' based on the current env.\n",
304
      "  The environment variables can either be used in paths, or as separate values:\n"
305
      "    data.location=$XDG_DATA_HOME/task/\n"
306
      "    default.project=$PROJECT",
307
      "", "");
×
308
  items.push_back(env_vars);
×
309

310
  /////////////////////////////////////////////////////////////////////////////
311
  // - Reports outside of context
312

313
  NewsItem contextless_reports(
314
      version, "Context-less reports", "",
315
      "  By default, every report is affected by currently active context.",
316
      "  You can now make a selected report ignore currently active context by setting\n"
317
      "  'report.<name>.context' configuration variable to 0.",
318
      "",
319
      "  This is useful for users who utilize a single place (such as project:Inbox)\n"
320
      "  to collect their new tasks that are then triaged on a regular basis\n"
321
      "  (such as in GTD methodology).\n"
322
      "  \n"
323
      "  In such a case, defining a report that filters for project:Inbox and making it\n"
324
      "  fully accessible from any context is a major usability improvement.",
325
      "");
×
326
  items.push_back(contextless_reports);
×
327

328
  /////////////////////////////////////////////////////////////////////////////
329
  // - Exporting a particular report
330

331
  NewsItem exportable_reports(
332
      version, "Exporting a particular report", "", "",
333
      "  You can now export the tasks listed by a particular report as JSON by simply\n"
334
      "  calling 'task export <report>'.\n",
335
      "  The export mirrors the filter and the sort order of the report.",
336
      "  This feature can be used to quickly process the data displayed in a particular\n"
337
      "  report using other CLI tools. For example, the following oneliner\n"
338
      "  \n"
339
      "      $ task export next | jq '.[].urgency' | datamash mean 1\n"
340
      "      3.3455535142857\n"
341
      "  \n"
342
      "  combines jq and GNU datamash to compute average urgency of the tasks displayed\n"
343
      "  in the 'next' report.",
344
      "");
×
345
  items.push_back(exportable_reports);
×
346

347
  /////////////////////////////////////////////////////////////////////////////
348
  // - Multi-day holidays
349

350
  NewsItem multi_holidays(
351
      version, "Multi-day holidays", "",
352
      "  Holidays are currently used in 'task calendar' to visualize the workload during\n"
353
      "  the upcoming weeks/months. Up to date country-specific holiday data files can be\n"
354
      "  obtained from our website, holidata.net.",
355
      "  Instead of single-day holiday entries only, Taskwarrior now supports holidays\n"
356
      "  that span a range of days (i.e. vacation).\n",
357
      "  Use a holiday.<name>.start and holiday.<name>.end to configure a multi-day holiday:\n"
358
      "  \n"
359
      "      holiday.sysadmin.name=System Administrator Appreciation Week\n"
360
      "      holiday.sysadmin.start=20100730\n"
361
      "      holiday.sysadmin.end=20100805",
362
      "", "");
×
363
  items.push_back(multi_holidays);
×
364

365
  /////////////////////////////////////////////////////////////////////////////
366
  // - Unicode 12
367

368
  NewsItem unicode_12(
369
      version, "Extended Unicode support (Unicode 12)", "", "",
370
      "  The support for Unicode character set was improved to support Unicode 12.\n"
371
      "  This means better support for various language-specific characters - and emojis!",
372
      "",
373
      "  Extended unicode support for language-specific characters helps non-English speakers.\n"
374
      "  While most users don't enter emojis as task metadata, automated task creation tools,\n"
375
      "  such as bugwarrior, might create tasks with exotic Unicode data.",
376
      "  You can try it out - 'task add Prepare for an 👽 invasion!'");
×
377
  items.push_back(unicode_12);
×
378

379
  /////////////////////////////////////////////////////////////////////////////
380
  // - The .by attribute modifier
381

382
  NewsItem by_modifier(
383
      version, "The .by attribute modifier", "", "",
384
      "  A new attribute modifier '.by' was introduced, equivalent to the operator '<='.\n",
385
      "  This modifier can be used to list all tasks due by the end of the months,\n"
386
      "  including the last day of the month, using: 'due.by:eom' query",
387
      "  There was no convenient way to express '<=' relation using attribute modifiers.\n"
388
      "  As a workaround, instead of 'due.by:eom' one could use 'due.before:eom+1d',\n"
389
      "  but that requires a certain amount of mental overhead.",
390
      "");
×
391
  items.push_back(by_modifier);
×
392

393
  /////////////////////////////////////////////////////////////////////////////
394
  // - Context-specific configuration overrides
395

396
  NewsItem context_config(
397
      version, "Context-specific configuration overrides", "", "",
398
      "  Any context can now define context-specific configuration overrides\n"
399
      "  via context.<name>.rc.<setting>=<value>.\n",
400
      "  This allows the user to customize the behaviour of Taskwarrior in a given context,\n"
401
      "  for example, to change the default command in the 'work' context to 'overdue':\n"
402
      "\n"
403
      "      $ task config context.work.rc.default.command overdue\n"
404
      "\n"
405
      "  Another example would be to ensure that while context 'work' is active, tasks get\n"
406
      "  stored in a ~/.worktasks directory:\n"
407
      "\n"
408
      "      $ task config context.work.rc.data.location=~/.worktasks",
409
      "", "");
×
410
  items.push_back(context_config);
×
411

412
  /////////////////////////////////////////////////////////////////////////////
413
  // - XDG config home support
414

415
  NewsItem xdg_support(
416
      version, "Support for XDG Base Directory Specification", "",
417
      "  The XDG Base Directory specification provides standard locations to store\n"
418
      "  application data, configuration, state, and cached data in order to keep $HOME\n"
419
      "  clutter-free. The locations are usually set to ~/.local/share, ~/.config,\n"
420
      "  ~/.local/state and ~/.cache respectively.",
421
      "  If taskrc is not found at '~/.taskrc', Taskwarrior will attempt to find it\n"
422
      "  at '$XDG_CONFIG_HOME/task/taskrc' (defaults to '~/.config/task/taskrc').",
423
      "",
424
      "  This allows users to fully follow XDG Base Directory Spec by moving their taskrc:\n"
425
      "      $ mkdir $XDG_CONFIG_HOME/task\n"
426
      "      $ mv ~/.taskrc $XDG_CONFIG_HOME/task/taskrc\n\n"
427
      "  and further setting:\n"
428
      "      data.location=$XDG_DATA_HOME/task/\n"
429
      "      hooks.location=$XDG_CONFIG_HOME/task/hooks/\n\n"
430
      "  Solutions in the past required symlinks or more cumbersome configuration overrides.",
431
      "  If you configure your data.location and hooks.location as above, ensure\n"
432
      "  that the XDG_DATA_HOME and XDG_CONFIG_HOME environment variables are set,\n"
433
      "  otherwise they're going to expand to empty string. Alternatively you can\n"
434
      "  hardcode the desired paths on your system.");
×
435
  items.push_back(xdg_support);
×
436

437
  /////////////////////////////////////////////////////////////////////////////
438
  // - Update holiday data
439

440
  NewsItem holidata_2022(
441
      version, "Updated holiday data for 2022", "", "",
442
      "  Holiday data has been refreshed for 2022 and five more holiday locales\n"
443
      "  have been added: fr-CA, hu-HU, pt-BR, sk-SK and sv-FI.",
444
      "",
445
      "  Refreshing the holiday data is part of every release. The addition of the new\n"
446
      "  locales allows us to better support users in those particular countries.");
×
447
  items.push_back(holidata_2022);
×
448
}
449

450
void NewsItem::version3_0_0(std::vector<NewsItem>& items) {
×
451
  Version version("3.0.0");
×
452
  NewsItem sync{
453
      version,
454
      /*title=*/"New data model and sync backend",
455
      /*bg_title=*/"",
456
      /*background=*/"",
457
      /*punchline=*/
458
      "The sync functionality for Taskwarrior has been rewritten entirely, and no longer\n"
459
      "supports taskserver/taskd. The most robust solution is a cloud-storage backend,\n"
460
      "although a less-mature taskchampion-sync-server is also available. See `task-sync(5)`\n"
461
      "For details. As part of this change, the on-disk storage format has also changed.\n",
462
      /*update=*/
463
      "This is a breaking upgrade: you must export your task database from 2.x and re-import\n"
464
      "it into 3.x. Hooks run during task import, so if you have any hooks defined,\n"
465
      "temporarily disable them for this operation.\n\n"
466
      "See https://taskwarrior.org/docs/upgrade-3/ for information on upgrading to Taskwarrior "
467
      "3.0.",
468
  };
×
469
  items.push_back(sync);
×
470
}
471

472
void NewsItem::version3_1_0(std::vector<NewsItem>& items) {
×
473
  Version version("3.1.0");
×
474
  NewsItem purge{
475
      version,
476
      /*title=*/"Purging Tasks, Manually or Automatically",
477
      /*bg_title=*/"",
478
      /*background=*/"",
479
      /*punchline=*/
480
      "Support for `task purge` has been restored, and new support added for automatically\n"
481
      "expiring old tasks.\n\n",
482
      /*update=*/
483
      "The `task purge` command removes tasks entirely, in contrast to `task delete` which merely\n"
484
      "sets the task status to 'Deleted'. This functionality existed in versions 2.x but was\n"
485
      "temporarily removed in 3.0.\n\n"
486
      "The new `purge.on-sync` configuration parameter controls automatic purging of old tasks.\n"
487
      "An old task is one with status 'Deleted' that has not been modified in 180 days. This\n"
488
      "functionality is optional and not enabled by default."};
×
489
  items.push_back(purge);
×
490
  NewsItem news{
491
      version,
492
      /*title=*/"Improved 'task news'",
493
      /*bg_title=*/"",
494
      /*background=*/"",
495
      /*punchline=*/
496
      "The news you are reading now is improved.\n\n",
497
      /*update=*/
498
      "The `task news` command now always shows all new information, not just 'major' news,\n"
499
      "and will only show that news once. New installs will assume all news has been read.\n"
500
      "Finally, news can be completely hidden by removing 'news' from the 'verbose' config."};
×
501
  items.push_back(news);
×
502
}
503

NEW
504
void NewsItem::version3_2_0(std::vector<NewsItem>& items) {
×
NEW
505
  Version version("3.2.0");
×
506
  NewsItem info{
507
      version,
508
      /*title=*/"`task info` Journal Restored",
509
      /*bg_title=*/"",
510
      /*background=*/"",
511
      /*punchline=*/"",
512
      /*update=*/
513
      "Support for the \"journal\" output in `task info` has been restored. The command now\n"
NEW
514
      "displays a list of changes made to the task, with timestamps.\n\n"};
×
NEW
515
  items.push_back(info);
×
516
}
517

518
////////////////////////////////////////////////////////////////////////////////
519
int CmdNews::execute(std::string& output) {
×
520
  auto words = Context::getContext().cli2.getWords();
×
521
  auto config = Context::getContext().config;
×
522

523
  // Supress compiler warning about unused argument
524
  output = "";
×
525

526
  std::vector<NewsItem> items = NewsItem::all();
×
527
  Version news_version(Context::getContext().config.get("news.version"));
×
528
  Version current_version = Version::Current();
×
529

530
  // 2.6.0 is the earliest version with news support.
531
  if (!news_version.is_valid()) news_version = Version("2.6.0");
×
532

533
  signal(SIGINT, signal_handler);
×
534

535
  // Remove items that have already been shown
536
  items.erase(std::remove_if(items.begin(), items.end(),
×
537
                             [&](const NewsItem& n) { return n._version <= news_version; }),
×
538
              items.end());
×
539

540
  Color bold = Color("bold");
×
541
  if (items.empty()) {
×
542
    std::cout << bold.colorize("You are up to date!\n");
×
543
  } else {
544
    // Print release notes
545
    std::cout << bold.colorize(
×
546
        format("\n"
×
547
               "================================================\n"
548
               "Taskwarrior {1} through {2} Release Highlights\n"
549
               "================================================\n",
550
               news_version, current_version));
×
551

552
    for (unsigned short i = 0; i < items.size(); i++) {
×
553
      std::cout << format("\n({1}/{2}) ", i + 1, items.size());
×
554
      items[i].render();
×
555
    }
556
    std::cout << "Thank you for catching up on the new features!\n";
×
557
  }
558
  wait_for_enter();
×
559

560
  // Display outro
561
  Datetime now;
×
562
  Datetime beginning(2006, 11, 29);
×
563
  Duration development_time = Duration(now - beginning);
×
564

565
  Color underline = Color("underline");
×
566

567
  std::stringstream outro;
×
568
  outro << underline.colorize(bold.colorize("Taskwarrior crowdfunding\n"));
×
569
  outro << format(
×
570
      "Taskwarrior has been in development for {1} years but its survival\n"
571
      "depends on your support!\n\n"
572
      "Please consider joining our {2} fundraiser to help us fund maintenance\n"
573
      "and development of new features:\n\n",
574
      std::lround(static_cast<float>(development_time.days()) / 365.25), now.year());
×
575
  outro << bold.colorize("    https://github.com/sponsors/GothenburgBitFactory/\n\n");
×
576
  outro << "Perks are available for our sponsors.\n";
×
577

578
  std::cout << outro.str();
×
579

580
  // Set a mark in the config to remember which version's release notes were displayed
581
  if (news_version != current_version) {
×
582
    CmdConfig::setConfigVariable("news.version", std::string(current_version), false);
×
583

584
    // Revert back to default signal handling after displaying the outro
585
    signal(SIGINT, SIG_DFL);
×
586

587
    std::string question = format(
588
        "\nWould you like to open Taskwarrior {1} fundraising campaign to read more?", now.year());
×
589

590
    std::vector<std::string> options{"yes", "no"};
×
591
    std::vector<std::string> matches;
×
592

593
    std::cout << question << " (YES/no) ";
×
594

595
    std::string answer;
×
596
    std::getline(std::cin, answer);
×
597

598
    if (std::cin.eof() || trim(answer).empty())
×
599
      answer = "yes";
×
600
    else
601
      lowerCase(trim(answer));
×
602

603
    autoComplete(answer, options, matches, 1);  // Hard-coded 1.
×
604

605
    if (matches.size() == 1 && matches[0] == "yes")
×
606
#if defined(DARWIN)
607
      system("open 'https://github.com/sponsors/GothenburgBitFactory/'");
608
#else
609
      system("xdg-open 'https://github.com/sponsors/GothenburgBitFactory/'");
×
610
#endif
611

612
    std::cout << std::endl;
×
613
  } else
×
614
    wait_for_enter();  // Do not display the outro and footnote at once
×
615

616
  return 0;
×
617
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc