From a6554161b86e19c521a9e80a16137fc39dfefe7c Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Wed, 15 May 2019 16:52:25 -0700 Subject: [PATCH] TCLAP support for translate command --- src/core/paths.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/core/paths.cpp b/src/core/paths.cpp index 6d93797..3dc8fb0 100644 --- a/src/core/paths.cpp +++ b/src/core/paths.cpp @@ -5,9 +5,11 @@ #include #include +#include "tclap/CmdLine.h" #include "output.hpp" #include "paths.hpp" +#include "version.hpp" #include "internal/core.hpp" 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 argv) { - if (argv.size() < 2) { - output::error("pass an argument"); - return; - } + TCLAP::CmdLine cmdparse("Translate a path from Windows to UNIX, or vice versa", ' ', version::short_version(), false); + + 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 - vector pathargs(argv.cbegin() + 1, argv.cend()); + TCLAP::UnlabeledMultiArg pathargcollector("path", "Paths to translate.", true, "PATH"); + cmdparse.add(pathargcollector); + + cmdparse.parse(argv); + + bool lazy = lazyarg.getValue(); + vector pathargs = pathargcollector.getValue(); for (auto arg : pathargs) { - cout << paths::translate(arg) << endl; + cout << paths::translate(arg, lazy) << endl; } }