@@ -52,23 +52,31 @@ auto app::run(const std::vector<std::string_view>& args) -> int {
52
52
53
53
int app::run_command (std::string const & command, const std::vector<std::string>& argv) {
54
54
if (command == " list" sv) {
55
- domain::application_service application_service;
56
- auto const count = application_service.list ();
57
- out << fmt::format (" total: {} issues\n " , count);
58
- return EXIT_SUCCESS;
55
+ return list ();
59
56
}
60
57
61
58
if (command == " create" sv) {
62
- auto const & parsed_args = docopt::docopt_parse (std::string (CREATE_USAGE), argv, false , false , false );
63
- auto const & title = parsed_args.at (" --title" ).asString ();
64
- auto const & description = parsed_args.at (" --descr" ).asString ();
65
-
66
- domain::application_service application_service;
67
- const auto issue_id = application_service.create (title, description);
68
- out << fmt::format (" Issue created: {}\n " , issue_id);
69
- return EXIT_SUCCESS;
59
+ return create (argv);
70
60
}
71
61
72
62
out << fmt::format (" fix: '{}' is not a fix command. See 'fix --help'.\n " , command);
73
63
return EXIT_FAILURE;
74
64
}
65
+
66
+ int app::list () {
67
+ domain::application_service application_service;
68
+ auto const count = application_service.list ();
69
+ out << fmt::format (" total: {} issues\n " , count);
70
+ return EXIT_SUCCESS;
71
+ }
72
+
73
+ int app::create (std::vector<std::string> const & argv) {
74
+ auto const & parsed_args = docopt::docopt_parse (std::string (CREATE_USAGE), argv, false , false , false );
75
+ auto const & title = parsed_args.at (" --title" ).asString ();
76
+ auto const & description = parsed_args.at (" --descr" ).asString ();
77
+
78
+ domain::application_service application_service;
79
+ const auto issue_id = application_service.create (title, description);
80
+ this ->out << fmt::format (" Issue created: {}\n " , issue_id);
81
+ return EXIT_SUCCESS;
82
+ }
0 commit comments