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

GothenburgBitFactory / taskwarrior / 13738481864

08 Mar 2025 02:20PM UTC coverage: 85.262% (+0.1%) from 85.128%
13738481864

push

github

djmitche
Remove sponsorship outro from 'task news'

19554 of 22934 relevant lines covered (85.26%)

23397.61 hits per line

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

54.92
/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 <shared.h>
37
#include <util.h>
38

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

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

51
////////////////////////////////////////////////////////////////////////////////
52
CmdNews::CmdNews() {
4,558✔
53
  _keyword = "news";
4,558✔
54
  _usage = "task          news";
4,558✔
55
  _description = "Displays news about the recent releases";
4,558✔
56
  _read_only = true;
4,558✔
57
  _displays_id = false;
4,558✔
58
  _needs_gc = false;
4,558✔
59
  _needs_recur_update = false;
4,558✔
60
  _uses_context = false;
4,558✔
61
  _accepts_filter = false;
4,558✔
62
  _accepts_modifications = false;
4,558✔
63
  _accepts_miscellaneous = false;
4,558✔
64
  _category = Command::Category::misc;
4,558✔
65
}
4,558✔
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,
8,330✔
100
                   const std::string& background, const std::string& punchline,
101
                   const std::string& update, const std::string& reasoning,
102
                   const std::string& actions) {
8,330✔
103
  _version = version;
8,330✔
104
  _title = title;
8,330✔
105
  _bg_title = bg_title;
8,330✔
106
  _background = background;
8,330✔
107
  _punchline = punchline;
8,330✔
108
  _update = update;
8,330✔
109
  _reasoning = reasoning;
8,330✔
110
  _actions = actions;
8,330✔
111
}
8,330✔
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() {
490✔
157
  std::vector<NewsItem> items;
490✔
158
  version2_6_0(items);
490✔
159
  version3_0_0(items);
490✔
160
  version3_1_0(items);
490✔
161
  version3_2_0(items);
490✔
162
  version3_3_0(items);
490✔
163
  return items;
490✔
164
}
×
165

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

348
  /////////////////////////////////////////////////////////////////////////////
349
  // - Multi-day holidays
350

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

366
  /////////////////////////////////////////////////////////////////////////////
367
  // - Unicode 12
368

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

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

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

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

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

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

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

438
  /////////////////////////////////////////////////////////////////////////////
439
  // - Update holiday data
440

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

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

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

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

519
void NewsItem::version3_3_0(std::vector<NewsItem>& items) {
490✔
520
  Version version("3.3.0");
490✔
521
  NewsItem info{
522
      version,
523
      /*title=*/"AWS S3 Sync",
524
      /*bg_title=*/"",
525
      /*background=*/"",
526
      /*punchline=*/"Use an AWS S3 bucket to sync Taskwarrior",
527
      /*update=*/
528
      "Taskwarrior now supports AWS as a backend for sync, in addition to existing support\n"
529
      "for GCP and taskchampion-sync-server. See `man task-sync` for details.\n\n"};
6,860✔
530
  items.push_back(info);
490✔
531
}
490✔
532

533
////////////////////////////////////////////////////////////////////////////////
534
int CmdNews::execute(std::string& output) {
×
535
  auto words = Context::getContext().cli2.getWords();
×
536
  auto config = Context::getContext().config;
×
537

538
  // Supress compiler warning about unused argument
539
  output = "";
×
540

541
  std::vector<NewsItem> items = NewsItem::all();
×
542
  Version news_version(Context::getContext().config.get("news.version"));
×
543
  Version current_version = Version::Current();
×
544

545
  // 2.6.0 is the earliest version with news support.
546
  if (!news_version.is_valid()) news_version = Version("2.6.0");
×
547

548
  signal(SIGINT, signal_handler);
×
549

550
  // Remove items that have already been shown
551
  items.erase(std::remove_if(items.begin(), items.end(),
×
552
                             [&](const NewsItem& n) { return n._version <= news_version; }),
×
553
              items.end());
×
554

555
  Color bold = Color("bold");
×
556
  if (items.empty()) {
×
557
    std::cout << bold.colorize("You are up to date!\n");
×
558
  } else {
559
    // Print release notes
560
    std::cout << bold.colorize(
×
561
        format("\n"
×
562
               "================================================\n"
563
               "Taskwarrior {1} through {2} Release Highlights\n"
564
               "================================================\n",
565
               news_version, current_version));
×
566

567
    for (unsigned short i = 0; i < items.size(); i++) {
×
568
      std::cout << format("\n({1}/{2}) ", i + 1, items.size());
×
569
      items[i].render();
×
570
    }
571
    std::cout << "Thank you for catching up on the new features!\n";
×
572
  }
573
  wait_for_enter();
×
574

575
  return 0;
×
576
}
×
577

578
bool CmdNews::should_nag() {
657✔
579
  if (!Context::getContext().verbose("news")) {
1,971✔
580
    return false;
146✔
581
  }
582

583
  Version news_version(Context::getContext().config.get("news.version"));
1,022✔
584
  if (!news_version.is_valid()) news_version = Version("2.6.0");
511✔
585

586
  Version current_version = Version::Current();
511✔
587

588
  if (news_version >= current_version) {
511✔
589
    return false;
21✔
590
  }
591

592
  // Check if there are actually any interesting news items to show.
593
  std::vector<NewsItem> items = NewsItem::all();
490✔
594
  for (auto& item : items) {
6,370✔
595
    if (item._version > news_version) {
6,370✔
596
      return true;
490✔
597
    }
598
  }
599

600
  return false;
×
601
}
490✔
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