TCLAP support for translate command
This commit is contained in:
parent
275a174941
commit
a6554161b8
@ -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;
|
TCLAP::SwitchArg lazyarg("l", "lazy", "Lazy path translating - don't read symlinks, just assume / is mounted on Z:");
|
||||||
}
|
cmdparse.add(lazyarg);
|
||||||
|
|
||||||
// TODO: tclap me later
|
TCLAP::UnlabeledMultiArg<string> pathargcollector("path", "Paths to translate.", true, "PATH");
|
||||||
vector<string> pathargs(argv.cbegin() + 1, argv.cend());
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user