TCLAP support for translate command

This commit is contained in:
Nicholas O'Connor 2019-05-15 16:52:25 -07:00
parent 275a174941
commit a6554161b8

View File

@ -5,9 +5,11 @@
#include <regex> #include <regex>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include "tclap/CmdLine.h"
#include "output.hpp" #include "output.hpp"
#include "paths.hpp" #include "paths.hpp"
#include "version.hpp"
#include "internal/core.hpp" #include "internal/core.hpp"
using namespace std; using namespace std;
@ -54,15 +56,20 @@ string cellar::paths::translate(std::string in_path, bool lazy) {
} }
void cellar::core::translate_command(int argc, vector<string> argv) { void cellar::core::translate_command(int argc, vector<string> argv) {
if (argv.size() < 2) { TCLAP::CmdLine cmdparse("Translate a path from Windows to UNIX, or vice versa", ' ', version::short_version(), false);
output::error("pass an argument");
return;
}
// TODO: tclap me later TCLAP::SwitchArg lazyarg("l", "lazy", "Lazy path translating - don't read symlinks, just assume / is mounted on Z:");
vector<string> pathargs(argv.cbegin() + 1, argv.cend()); cmdparse.add(lazyarg);
TCLAP::UnlabeledMultiArg<string> pathargcollector("path", "Paths to translate.", true, "PATH");
cmdparse.add(pathargcollector);
cmdparse.parse(argv);
bool lazy = lazyarg.getValue();
vector<string> pathargs = pathargcollector.getValue();
for (auto arg : pathargs) { for (auto arg : pathargs) {
cout << paths::translate(arg) << endl; cout << paths::translate(arg, lazy) << endl;
} }
} }