44#include  < string> 
55
66#include  < git2.h> 
7+ #include  < termcolor/termcolor.hpp> 
78
89#include  " status_subcommand.hpp" 
910#include  " ../wrapper/status_wrapper.hpp" 
@@ -45,16 +46,16 @@ struct status_messages
4546const  std::map<git_status_t , status_messages> status_msg_map =   // TODO : check spaces in short_mod
4647{
4748    { GIT_STATUS_CURRENT, {" " " " 
48-     { GIT_STATUS_INDEX_NEW, {" A  " " \t   new  file:" 
49-     { GIT_STATUS_INDEX_MODIFIED, {" M  " " \t   modified :" 
50-     { GIT_STATUS_INDEX_DELETED, {" D  " " \t   deleted :" 
51-     { GIT_STATUS_INDEX_RENAMED, {" R  " " \t   renamed :" 
52-     { GIT_STATUS_INDEX_TYPECHANGE, {" T  " " \t   typechange :" 
49+     { GIT_STATUS_INDEX_NEW, {" A  " " \t  new  file:" 
50+     { GIT_STATUS_INDEX_MODIFIED, {" M  " " \t  modified :" 
51+     { GIT_STATUS_INDEX_DELETED, {" D  " " \t  deleted :" 
52+     { GIT_STATUS_INDEX_RENAMED, {" R  " " \t  renamed :" 
53+     { GIT_STATUS_INDEX_TYPECHANGE, {" T  " " \t  typechange :" 
5354    { GIT_STATUS_WT_NEW, {" ?? " " " 
54-     { GIT_STATUS_WT_MODIFIED, {"  M " " \t   modified :" 
55-     { GIT_STATUS_WT_DELETED, {"  D " " \t   deleted :" 
56-     { GIT_STATUS_WT_TYPECHANGE, {"  T " " \t   typechange :" 
57-     { GIT_STATUS_WT_RENAMED, {"  R " " \t   renamed :" 
55+     { GIT_STATUS_WT_MODIFIED, {"  M " " \t  modified :" 
56+     { GIT_STATUS_WT_DELETED, {"  D " " \t  deleted :" 
57+     { GIT_STATUS_WT_TYPECHANGE, {"  T " " \t  typechange :" 
58+     { GIT_STATUS_WT_RENAMED, {"  R " " \t  renamed :" 
5859    { GIT_STATUS_WT_UNREADABLE, {" " " " 
5960    { GIT_STATUS_IGNORED, {" !! " " " 
6061    { GIT_STATUS_CONFLICTED, {" " " " 
@@ -78,7 +79,7 @@ std::string get_print_status(git_status_t status, output_format of)
7879    std::string entry_status;
7980    if  ((of == output_format::DEFAULT) || (of == output_format::LONG))
8081    {
81-         entry_status = status_msg_map.at (status).long_mod  + " \t " 
82+         entry_status = status_msg_map.at (status).long_mod  + "     " 
8283    }
8384    else  if  (of == output_format::SHORT)
8485    {
@@ -139,24 +140,31 @@ std::vector<print_entry> get_entries_to_print(git_status_t status, status_list_w
139140    return  entries_to_print;
140141}
141142
142- void  print_entries (std::vector<print_entry> entries_to_print)
143+ void  print_entries (std::vector<print_entry> entries_to_print,  bool  is_long, stream_colour_fn colour )
143144{
144145    for  (auto  e: entries_to_print)
145146    {
146-         std::cout << e.status  << e.item  << std::endl;
147+         if  (is_long)
148+         {
149+             std::cout << colour << e.status  << e.item  << termcolor::reset << std::endl;
150+         }
151+         else 
152+         {
153+             std::cout << colour << e.status  << termcolor::reset << e.item  << std::endl;
154+         }
147155    }
148156}
149157
150158void  print_not_tracked (const  std::vector<print_entry>& entries_to_print, const  std::set<std::string>& tracked_dir_set,
151-         std::set<std::string>& untracked_dir_set)
159+         std::set<std::string>& untracked_dir_set,  bool  is_long, stream_colour_fn colour )
152160{
153161    std::vector<print_entry> not_tracked_entries_to_print{};
154162    for  (auto  e: entries_to_print)
155163    {
156164        const  size_t  first_slash_idx = e.item .find (' /' 
157165        if  (std::string::npos != first_slash_idx)
158166        {
159-             auto  directory = e.item .substr (0 , first_slash_idx);
167+             auto  directory = " \t "  +  e.item .substr (0 , first_slash_idx) +  " / " 
160168            if  (tracked_dir_set.contains (directory))
161169            {
162170                not_tracked_entries_to_print.push_back (e);
@@ -177,7 +185,7 @@ void print_not_tracked(const std::vector<print_entry>& entries_to_print, const s
177185            not_tracked_entries_to_print.push_back (e);
178186        }
179187    }
180-     print_entries (not_tracked_entries_to_print);
188+     print_entries (not_tracked_entries_to_print, is_long, colour );
181189}
182190
183191void  status_subcommand::run ()
@@ -220,17 +228,19 @@ void status_subcommand::run()
220228            std::cout  << " ## " 
221229        }
222230    }
231+ 
223232    if  (sl.has_tobecommited_header ())
224233    {
234+         stream_colour_fn colour = termcolor::green;
225235        if  (is_long)
226236        {
227-             std::cout << tobecommited_header << std::endl ;
237+             std::cout << tobecommited_header;
228238        }
229-         print_entries (get_entries_to_print (GIT_STATUS_INDEX_NEW, sl, true , of, &tracked_dir_set));
230-         print_entries (get_entries_to_print (GIT_STATUS_INDEX_MODIFIED, sl, true , of, &tracked_dir_set));
231-         print_entries (get_entries_to_print (GIT_STATUS_INDEX_DELETED, sl, true , of, &tracked_dir_set));
232-         print_entries (get_entries_to_print (GIT_STATUS_INDEX_RENAMED, sl, true , of, &tracked_dir_set));
233-         print_entries (get_entries_to_print (GIT_STATUS_INDEX_TYPECHANGE, sl, true , of, &tracked_dir_set));
239+         print_entries (get_entries_to_print (GIT_STATUS_INDEX_NEW, sl, true , of, &tracked_dir_set), is_long, colour );
240+         print_entries (get_entries_to_print (GIT_STATUS_INDEX_MODIFIED, sl, true , of, &tracked_dir_set), is_long, colour );
241+         print_entries (get_entries_to_print (GIT_STATUS_INDEX_DELETED, sl, true , of, &tracked_dir_set), is_long, colour );
242+         print_entries (get_entries_to_print (GIT_STATUS_INDEX_RENAMED, sl, true , of, &tracked_dir_set), is_long, colour );
243+         print_entries (get_entries_to_print (GIT_STATUS_INDEX_TYPECHANGE, sl, true , of, &tracked_dir_set), is_long, colour );
234244        if  (is_long)
235245        {
236246            std::cout << std::endl;
@@ -239,44 +249,46 @@ void status_subcommand::run()
239249
240250    if  (sl.has_notstagged_header ())
241251    {
252+         stream_colour_fn colour = termcolor::red;
242253        if  (is_long)
243254        {
244-             std::cout << notstagged_header << std::endl ;
255+             std::cout << notstagged_header;
245256        }
246-         print_entries (get_entries_to_print (GIT_STATUS_WT_MODIFIED, sl, false , of, &tracked_dir_set));
247-         print_entries (get_entries_to_print (GIT_STATUS_WT_DELETED, sl, false , of, &tracked_dir_set));
248-         print_entries (get_entries_to_print (GIT_STATUS_WT_TYPECHANGE, sl, false , of, &tracked_dir_set));
249-         print_entries (get_entries_to_print (GIT_STATUS_WT_RENAMED, sl, false , of, &tracked_dir_set));
257+         print_entries (get_entries_to_print (GIT_STATUS_WT_MODIFIED, sl, false , of, &tracked_dir_set), is_long, colour );
258+         print_entries (get_entries_to_print (GIT_STATUS_WT_DELETED, sl, false , of, &tracked_dir_set), is_long, colour );
259+         print_entries (get_entries_to_print (GIT_STATUS_WT_TYPECHANGE, sl, false , of, &tracked_dir_set), is_long, colour );
260+         print_entries (get_entries_to_print (GIT_STATUS_WT_RENAMED, sl, false , of, &tracked_dir_set), is_long, colour );
250261        if  (is_long)
251262        {
252263            std::cout << std::endl;
253264        }
254265    }
255266
256- 
257267    if  (sl.has_untracked_header ())
258268    {
269+         stream_colour_fn colour = termcolor::red;
259270        if  (is_long)
260271        {
261-             std::cout << untracked_header << std::endl ;
272+             std::cout << untracked_header;
262273        }
263-         print_not_tracked (get_entries_to_print (GIT_STATUS_WT_NEW, sl, false , of), tracked_dir_set, untracked_dir_set);
274+         print_not_tracked (get_entries_to_print (GIT_STATUS_WT_NEW, sl, false , of), tracked_dir_set, untracked_dir_set, is_long, colour );
264275        if  (is_long)
265276        {
266277            std::cout << std::endl;
267278        }
268279    }
269280
270-     if  (sl.has_ignored_header ())
271-     {
272-         if  (is_long)
273-         {
274-             std::cout << ignored_header << std::endl;
275-         }
276-         print_not_tracked (get_entries_to_print (GIT_STATUS_IGNORED, sl, false , of), tracked_dir_set, untracked_dir_set);
277-         if  (is_long)
278-         {
279-             std::cout << std::endl;
280-         }
281-     }
281+     //  if (sl.has_ignored_header())
282+     //  {
283+     //      stream_colour_fn colour = termcolor::red;
284+     //      if (is_long)
285+     //      {
286+     //          std::cout << ignored_header;
287+     //      }
288+     //      print_not_tracked(get_entries_to_print(GIT_STATUS_IGNORED, sl, false, of), tracked_dir_set, untracked_dir_set, is_long, colour);
289+     //      if (is_long)
290+     //      {
291+     //          std::cout << std::endl;
292+     //      }
293+     //  }
282294}
0 commit comments