Applied modified version of -q patch from #3177
This commit is contained in:
parent
ace4ca441e
commit
e71585b8f4
|
@ -272,6 +272,9 @@ public:
|
|||
// Get the accumulated output
|
||||
std::string getOutput() { return output_acc; }
|
||||
|
||||
// is -q (quiet) provided ?
|
||||
bool is_quiet() { return opt_quiet; }
|
||||
|
||||
int cmd_print_package_list(bool print_path);
|
||||
|
||||
int cmd_list_duplicates();
|
||||
|
@ -309,6 +312,8 @@ public:
|
|||
bool opt_display_duplicate_pkgs;
|
||||
|
||||
private:
|
||||
// is quiet
|
||||
bool opt_quiet;
|
||||
bool cache_lock_failed;
|
||||
bool crawled;
|
||||
std::string getCachePath();
|
||||
|
|
|
@ -39,11 +39,27 @@ int main(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
int ret;
|
||||
bool quiet;
|
||||
try
|
||||
{
|
||||
// Declare ROSPack instance inside the try block because its
|
||||
// constructor can throw (e.g., when ROS_ROOT isn't set).
|
||||
rospack::ROSPack rp;
|
||||
ret = rp.run(argc, argv);
|
||||
printf("%s", rp.getOutput().c_str());
|
||||
// Separate try block for running the command, to allow for suppressing
|
||||
// error output when -q is given.
|
||||
try
|
||||
{
|
||||
ret = rp.run(argc, argv);
|
||||
printf("%s", rp.getOutput().c_str());
|
||||
}
|
||||
catch(std::runtime_error &e)
|
||||
{
|
||||
// Return code is -1 no matter what, but don't rethrow if we were
|
||||
// asked to be quiet.
|
||||
ret = -1;
|
||||
if(!rp.is_quiet())
|
||||
throw;
|
||||
}
|
||||
}
|
||||
catch(std::runtime_error &e)
|
||||
{
|
||||
|
|
|
@ -632,8 +632,9 @@ VecPkg Package::deleted_pkgs;
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ROSPack::ROSPack() : ros_root(NULL), cache_lock_failed(false), crawled(false),
|
||||
my_argc(0), my_argv(NULL), opt_profile_length(0), total_num_pkgs(0),
|
||||
ROSPack::ROSPack() : ros_root(NULL), opt_quiet(false),
|
||||
cache_lock_failed(false), crawled(false), my_argc(0),
|
||||
my_argv(NULL), opt_profile_length(0), total_num_pkgs(0),
|
||||
duplicate_packages_found(false)
|
||||
{
|
||||
g_rospack = this;
|
||||
|
@ -697,7 +698,9 @@ const char* ROSPack::usage()
|
|||
" libs-only-L [--deps-only] [package]\n"
|
||||
" libs-only-l [--deps-only] [package]\n"
|
||||
" libs-only-other [--deps-only] [package]\n"
|
||||
" profile [--length=<length>] [--zombie-only]\n\n"
|
||||
" profile [--length=<length>] [--zombie-only]\n"
|
||||
" Extra options:\n"
|
||||
" -q Quiets error reports.\n\n"
|
||||
" If [package] is omitted, the current working directory\n"
|
||||
" is used (if it contains a manifest.xml).\n\n";
|
||||
}
|
||||
|
@ -1137,6 +1140,7 @@ int ROSPack::run(int argc, char **argv)
|
|||
const char* opt_length_name = "--length=";
|
||||
const char* opt_top_name = "--top=";
|
||||
const char* opt_target_name = "--target=";
|
||||
const char* opt_quiet_name = "-q";
|
||||
|
||||
// Reset to defaults.
|
||||
opt_deps_only = false;
|
||||
|
@ -1174,6 +1178,8 @@ int ROSPack::run(int argc, char **argv)
|
|||
opt_deps_only=true;
|
||||
else if(!strcmp(argv[i], opt_zombie_name))
|
||||
opt_profile_zombie_only=true;
|
||||
else if(!strcmp(argv[i], opt_quiet_name))
|
||||
opt_quiet=true;
|
||||
else if(!strncmp(argv[i], opt_target_name, strlen(opt_target_name)))
|
||||
{
|
||||
if(opt_target.size())
|
||||
|
|
Loading…
Reference in New Issue