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

GothenburgBitFactory / taskwarrior / 10152339701

29 Jul 2024 09:45PM UTC coverage: 84.437% (+0.07%) from 84.372%
10152339701

push

github

web-flow
Merge pull request #3566 from felixschurk/add-clang-format

Add clang-format to enforce style guide

12359 of 13760 new or added lines in 147 files covered. (89.82%)

123 existing lines in 42 files now uncovered.

19070 of 22585 relevant lines covered (84.44%)

19724.02 hits per line

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

96.97
/src/commands/CmdAdd.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 <CmdAdd.h>
31
#include <Context.h>
32
#include <format.h>
33
#include <main.h>
34

35
////////////////////////////////////////////////////////////////////////////////
36
CmdAdd::CmdAdd() {
4,389✔
37
  _keyword = "add";
4,389✔
38
  _usage = "task          add <mods>";
4,389✔
39
  _description = "Adds a new task";
4,389✔
40
  _read_only = false;
4,389✔
41
  _displays_id = false;
4,389✔
42
  _needs_gc = false;
4,389✔
43
  _uses_context = true;
4,389✔
44
  _accepts_filter = false;
4,389✔
45
  _accepts_modifications = true;
4,389✔
46
  _accepts_miscellaneous = false;
4,389✔
47
  _category = Command::Category::operation;
4,389✔
48
}
4,389✔
49

50
////////////////////////////////////////////////////////////////////////////////
51
int CmdAdd::execute(std::string& output) {
1,611✔
52
  // Apply the command line modifications to the new task.
53
  Task task;
1,611✔
54

55
  // the task is empty, but DOM references can refer to earlier parts of the
56
  // command line, e.g., `task add due:20110101 wait:due`.
57
  task.modify(Task::modReplace, true);
1,611✔
58
  Context::getContext().tdb2.add(task);
1,221✔
59

60
  // Do not display ID 0, users cannot query by that
61
  auto status = task.getStatus();
1,213✔
62

63
  // We may have a situation where both new-id and new-uuid config
64
  // variables are set. In that case, we'll show the new-uuid, as
65
  // it's enduring and never changes, and it's unlikely the caller
66
  // asked for this if they just wanted a human-friendly number.
67

68
  if (Context::getContext().verbose("new-uuid") && status == Task::recurring)
1,213✔
NEW
69
    output += format("Created task {1} (recurrence template).\n", task.get("uuid"));
×
70

71
  else if (Context::getContext().verbose("new-uuid") ||
3,636✔
72
           (Context::getContext().verbose("new-id") &&
2,423✔
73
            (status == Task::completed || status == Task::deleted)))
1,096✔
74
    output += format("Created task {1}.\n", task.get("uuid"));
3✔
75

76
  else if (Context::getContext().verbose("new-id") &&
1,279✔
77
           (status == Task::pending || status == Task::waiting))
69✔
78
    output += format("Created task {1}.\n", task.id);
1,037✔
79

80
  else if (Context::getContext().verbose("new-id") && status == Task::recurring)
173✔
81
    output += format("Created task {1} (recurrence template).\n", task.id);
59✔
82

83
  if (Context::getContext().verbose("project"))
1,213✔
84
    Context::getContext().footnote(onProjectChange(task));
1,095✔
85

86
  return 0;
1,213✔
87
}
1,611✔
88

89
////////////////////////////////////////////////////////////////////////////////
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