1 /* 2 * Copyright 2012, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "CliDebugReportCommand.h" 8 9 #include <Entry.h> 10 #include <FindDirectory.h> 11 #include <Path.h> 12 #include <String.h> 13 14 #include "CliContext.h" 15 #include "UiUtils.h" 16 #include "UserInterface.h" 17 18 19 CliDebugReportCommand::CliDebugReportCommand() 20 : 21 CliCommand("save debug report", 22 "%s\n" 23 "Saves a debug information report for the current team.") 24 { 25 } 26 27 28 void 29 CliDebugReportCommand::Execute(int argc, const char* const* argv, CliContext& context) 30 { 31 BPath path; 32 if (argc > 1) { 33 path.SetTo(argv[1]); 34 if (path.InitCheck() != B_OK) { 35 printf("Invalid report path %s given.\n", argv[1]); 36 return; 37 } 38 } else { 39 char buffer[B_FILE_NAME_LENGTH]; 40 UiUtils::ReportNameForTeam(context.GetTeam(), buffer, sizeof(buffer)); 41 find_directory(B_DESKTOP_DIRECTORY, &path); 42 path.Append(buffer); 43 } 44 45 entry_ref ref; 46 if (get_ref_for_path(path.Path(), &ref) == B_OK) { 47 printf("Saving debug information report to %s...\n", path.Path()); 48 context.GetUserInterfaceListener()->DebugReportRequested(&ref); 49 } 50 } 51