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

GothenburgBitFactory / taskwarrior / 10454226805

19 Aug 2024 01:22PM UTC coverage: 84.843% (-0.009%) from 84.852%
10454226805

push

github

web-flow
Bump docker/build-push-action from 6.6.1 to 6.7.0 (#3602)

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.6.1 to 6.7.0.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v6.6.1...v6.7.0)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

18987 of 22379 relevant lines covered (84.84%)

23089.67 hits per line

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

7.07
/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);
×
161
  return items;
×
162
}
163

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

346
  /////////////////////////////////////////////////////////////////////////////
347
  // - Multi-day holidays
348

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

364
  /////////////////////////////////////////////////////////////////////////////
365
  // - Unicode 12
366

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

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

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

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

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

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

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

436
  /////////////////////////////////////////////////////////////////////////////
437
  // - Update holiday data
438

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

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

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

503
////////////////////////////////////////////////////////////////////////////////
504
int CmdNews::execute(std::string& output) {
×
505
  auto words = Context::getContext().cli2.getWords();
×
506
  auto config = Context::getContext().config;
×
507

508
  // Supress compiler warning about unused argument
509
  output = "";
×
510

511
  std::vector<NewsItem> items = NewsItem::all();
×
512
  Version news_version(Context::getContext().config.get("news.version"));
×
513
  Version current_version = Version::Current();
×
514

515
  // 2.6.0 is the earliest version with news support.
516
  if (!news_version.is_valid()) news_version = Version("2.6.0");
×
517

518
  signal(SIGINT, signal_handler);
×
519

520
  // Remove items that have already been shown
521
  items.erase(std::remove_if(items.begin(), items.end(),
×
522
                             [&](const NewsItem& n) { return n._version <= news_version; }),
×
523
              items.end());
×
524

525
  Color bold = Color("bold");
×
526
  if (items.empty()) {
×
527
    std::cout << bold.colorize("You are up to date!\n");
×
528
  } else {
529
    // Print release notes
530
    std::cout << bold.colorize(
×
531
        format("\n"
×
532
               "================================================\n"
533
               "Taskwarrior {1} through {2} Release Highlights\n"
534
               "================================================\n",
535
               news_version, current_version));
×
536

537
    for (unsigned short i = 0; i < items.size(); i++) {
×
538
      std::cout << format("\n({1}/{2}) ", i + 1, items.size());
×
539
      items[i].render();
×
540
    }
541
    std::cout << "Thank you for catching up on the new features!\n";
×
542
  }
543
  wait_for_enter();
×
544

545
  // Display outro
546
  Datetime now;
×
547
  Datetime beginning(2006, 11, 29);
×
548
  Duration development_time = Duration(now - beginning);
×
549

550
  Color underline = Color("underline");
×
551

552
  std::stringstream outro;
×
553
  outro << underline.colorize(bold.colorize("Taskwarrior crowdfunding\n"));
×
554
  outro << format(
×
555
      "Taskwarrior has been in development for {1} years but its survival\n"
556
      "depends on your support!\n\n"
557
      "Please consider joining our {2} fundraiser to help us fund maintenance\n"
558
      "and development of new features:\n\n",
559
      std::lround(static_cast<float>(development_time.days()) / 365.25), now.year());
×
560
  outro << bold.colorize("    https://github.com/sponsors/GothenburgBitFactory/\n\n");
×
561
  outro << "Perks are available for our sponsors.\n";
×
562

563
  std::cout << outro.str();
×
564

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

569
    // Revert back to default signal handling after displaying the outro
570
    signal(SIGINT, SIG_DFL);
×
571

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

575
    std::vector<std::string> options{"yes", "no"};
×
576
    std::vector<std::string> matches;
×
577

578
    std::cout << question << " (YES/no) ";
×
579

580
    std::string answer;
×
581
    std::getline(std::cin, answer);
×
582

583
    if (std::cin.eof() || trim(answer).empty())
×
584
      answer = "yes";
×
585
    else
586
      lowerCase(trim(answer));
×
587

588
    autoComplete(answer, options, matches, 1);  // Hard-coded 1.
×
589

590
    if (matches.size() == 1 && matches[0] == "yes")
×
591
#if defined(DARWIN)
592
      system("open 'https://github.com/sponsors/GothenburgBitFactory/'");
593
#else
594
      system("xdg-open 'https://github.com/sponsors/GothenburgBitFactory/'");
×
595
#endif
596

597
    std::cout << std::endl;
×
598
  } else
×
599
    wait_for_enter();  // Do not display the outro and footnote at once
×
600

601
  return 0;
×
602
}
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

© 2025 Coveralls, Inc