@@ -52,23 +52,31 @@ auto app::run(const std::vector<std::string_view>& args) -> int {
5252
5353int app::run_command (std::string const & command, const std::vector<std::string>& argv) {
5454 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 ();
5956 }
6057
6158 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);
7060 }
7161
7262 out << fmt::format (" fix: '{}' is not a fix command. See 'fix --help'.\n " , command);
7363 return EXIT_FAILURE ;
7464}
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