aboutsummaryrefslogtreecommitdiff
path: root/src/dmtool.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-05-06 17:00:00 -0400
committerYour Name <you@example.com>2021-05-06 17:00:00 -0400
commitbf6db4e57895430d84503e800cec9e8b407212a8 (patch)
treebc21559fc0bff2ad616c5d69a45b5a22cc8cea60 /src/dmtool.cc
parent5ed030a38810e4a3bb9c969db6892065581340c6 (diff)
downloaddmtool-bf6db4e57895430d84503e800cec9e8b407212a8.tar.gz
dmtool-bf6db4e57895430d84503e800cec9e8b407212a8.tar.bz2
dmtool-bf6db4e57895430d84503e800cec9e8b407212a8.zip
Added a real configuration file (plus a dependency on libconfuse)
Diffstat (limited to 'src/dmtool.cc')
-rw-r--r--src/dmtool.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/dmtool.cc b/src/dmtool.cc
index 30f73b5..3c5d3a1 100644
--- a/src/dmtool.cc
+++ b/src/dmtool.cc
@@ -41,18 +41,19 @@ std::vector<std::string> extractFlags(std::vector<std::string>& args) {
}
int main(int argc, char *argv[]) {
- std::string exename = argv[0];
- std::vector<std::string> args(&argv[1], &argv[argc]);
- std::vector<std::string> flags = extractFlags(args);
- cmd::mkdir({cmd::getTruePath("")});
- if(args.empty()) {
- std::cout << cmd::list(args);
- return 0;
- }
- std::string cmd = args[0];
- std::vector<std::string> argsOrig(args);
- args.erase(args.begin());
+ // Full thing is surrounded in try/catch to pleasantly print out any errors
try {
+ std::string exename = argv[0];
+ std::vector<std::string> args(&argv[1], &argv[argc]);
+ std::vector<std::string> flags = extractFlags(args);
+ cmd::mkdir({cmd::getTruePath("")});
+ if(args.empty()) {
+ std::cout << cmd::list(args);
+ return 0;
+ }
+ std::string cmd = args[0];
+ std::vector<std::string> argsOrig(args);
+ args.erase(args.begin());
checkArgs(cmd, args);
if(cmd == "ls") std::cout << cmd::list(args);
else if(cmd == "cp") std::cout << cmd::cp(args);