Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Usage message when command is invoked incorrectly

  • Loading branch information...
commit f20952a7ab5d72e03dde601838a8a01e4dfc5830 1 parent 208a500
@exclipy authored
Showing with 16 additions and 3 deletions.
  1. +6 −1 clic_add.cpp
  2. +5 −1 clic_clear.cpp
  3. +5 −1 clic_rm.cpp
View
7 clic_add.cpp
@@ -74,7 +74,12 @@ enum CXChildVisitResult visitorFunction(
}
int main(int argc, const char* argv[]) {
- assert(argc >= 4);
+ if (argc < 4) {
+ std::cerr << "Usage:\n"
+ << " " << argv[0] << " <dbFilename> <indexFilename> <sourceFilename>\n";
+ return 1;
+ }
+
const char* dbFilename = argv[1];
const char* indexFilename = argv[2];
const char* sourceFilename = argv[argc-1];
View
6 clic_clear.cpp
@@ -2,7 +2,11 @@
#include <cassert>
int main(int argc, char* argv[]) {
- assert(argc == 2);
+ if (argc != 2) {
+ std::cerr << "Usage:\n"
+ << " " << argv[0] << " <dbFilename>\n";
+ return 1;
+ }
ClicDb db(argv[1]);
db.clear();
}
View
6 clic_rm.cpp
@@ -9,7 +9,11 @@
#include <iostream>
int main(int argc, char* argv[]) {
- assert(argc == 3);
+ if (argc != 3) {
+ std::cerr << "Usage:\n"
+ << " " << argv[0] << " <dbFilename> <indexFilename>\n";
+ return 1;
+ }
ClicDb db(argv[1]);
Please sign in to comment.
Something went wrong with that request. Please try again.