added cmdline parser
This commit is contained in:
parent
e09a3d34bc
commit
e895474f6b
|
@ -5,7 +5,7 @@ endif()
|
|||
# We can't use rosbuild/rosbuild.cmake here, because rosbuild.cmake
|
||||
# requires rospack, and we're in the process of building rospack.
|
||||
cmake_minimum_required(VERSION 2.4.6)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
|
||||
|
@ -127,7 +127,7 @@ add_custom_target(gcoverage)
|
|||
# tinyxml-2.5.3/tinyxmlerror.cpp)
|
||||
#add_executable(rpexe rp_main.cpp)
|
||||
#set_target_properties(rpexe PROPERTIES OUTPUT_NAME rp)
|
||||
#target_link_libraries(rpexe rp boost_filesystem boost_system)
|
||||
#target_link_libraries(rpexe rp boost_filesystem boost_system boost_program_options)
|
||||
#add_executable(rs rs_main.cpp)
|
||||
#target_link_libraries(rs rp boost_filesystem boost_system)
|
||||
# Uncomment above for new rospack
|
||||
|
|
|
@ -27,12 +27,60 @@
|
|||
|
||||
#include "rp.h"
|
||||
#include <boost/program_options.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
int
|
||||
parse_args(int argc, char** argv)
|
||||
{
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()
|
||||
("command", po::value<std::string>(), "command")
|
||||
("package", po::value<std::string>(), "package")
|
||||
("target", po::value<std::string>(), "target")
|
||||
("deps-only", "deps-only")
|
||||
("lang", po::value<std::string>(), "lang")
|
||||
("attrib", po::value<std::string>(), "attrib")
|
||||
("top", po::value<std::string>(), "top")
|
||||
("length", po::value<std::string>(), "length")
|
||||
("zombie-only", "zombie-only");
|
||||
|
||||
po::positional_options_description pd;
|
||||
pd.add("command", 1).add("package", 1);
|
||||
po::variables_map vm;
|
||||
try
|
||||
{
|
||||
po::store(po::command_line_parser(argc, argv).options(desc).positional(pd).run(), vm);
|
||||
}
|
||||
catch(boost::program_options::error e)
|
||||
{
|
||||
fprintf(stderr, "Error parsing command-line options: %s\n", e.what());
|
||||
// TODO: print USAGE
|
||||
return 1;
|
||||
}
|
||||
po::notify(vm);
|
||||
|
||||
for(po::variables_map::const_iterator it = vm.begin();
|
||||
it != vm.end();
|
||||
++it)
|
||||
{
|
||||
printf("%s:%s:\n", it->first.c_str(), it->second.as<std::string>().c_str());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
rospack::Rospack rp;
|
||||
int ret;
|
||||
|
||||
ret = parse_args(argc, argv);
|
||||
if(ret)
|
||||
return ret;
|
||||
|
||||
rospack::Rospack rp;
|
||||
std::vector<std::string> search_path;
|
||||
search_path.push_back("/Users/gerkey/code/ros/ros");
|
||||
search_path.push_back("/Users/gerkey/code/ros/ros/tools/rospack");
|
||||
|
@ -42,7 +90,7 @@ main(int argc, char** argv)
|
|||
//rp.debug_dump();
|
||||
|
||||
std::string rospack_path = rp.find("rospack");
|
||||
printf("rospack:%s:\n", rospack_path.c_str());
|
||||
//printf("rospack:%s:\n", rospack_path.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue