Skip to content

Commit 81ce342

Browse files
committed
Move list functionality to application service
The domain functionality does not belong into the CLI app itself
1 parent 4724eac commit 81ce342

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/domain/application_service.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ std::string application_service::create(std::string_view title, std::string_view
2424

2525
return id_prefix + "-0000000"s;
2626
}
27+
28+
size_t application_service::list() const { // NOLINT
29+
return 0;
30+
}

src/domain/application_service.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class application_service {
99
public:
1010
// cppcheck-suppress functionStatic
1111
std::string create(std::string_view title, std::string_view description);
12+
13+
// cppcheck-suppress functionStatic
14+
size_t list() const;
1215
};
1316

1417
}

src/fix_cli/app.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ auto app::run(const std::vector<std::string_view>& args) -> int {
5252

5353
int app::run_command(std::string const& command, const std::vector<std::string>& argv) {
5454
if (command == "list"sv) {
55-
out << "total: 0 issues\n";
55+
domain::application_service application_service;
56+
auto const count = application_service.list();
57+
out << fmt::format("total: {} issues\n", count);
5658
return EXIT_SUCCESS;
5759
}
5860

test/domain/application_service_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ TEST_CASE("Create issue returns issue ID") {
1616
auto const id_pattern = id_prefix + "-[0-9a-f]{7}"s;
1717
CHECK_THAT(application_service.create(title, description), Catch::Matches(id_pattern));
1818
}
19+
20+
TEST_CASE("List issues returns number of issues") {
21+
application_service application_service;
22+
CHECK(application_service.list() == 0);
23+
}

0 commit comments

Comments
 (0)