Permalink
Browse files

Replaced docopt with getopt_long

  • Loading branch information...
insomniacslk committed Oct 2, 2016
1 parent 294aaa0 commit 8a3ae7513645afdad5eabd8d6f368383dff98c8b
Showing with 77 additions and 1,949 deletions.
  1. +1 −9 CMakeLists.txt
  2. +0 −88 include/docopt/docopt.h
  3. +0 −674 include/docopt/docopt_private.h
  4. +0 −120 include/docopt/docopt_util.h
  5. +0 −340 include/docopt/docopt_value.h
  6. +0 −685 src/docopt/docopt.cpp
  7. +76 −33 src/main.cc
View
@@ -12,7 +12,6 @@ list(APPEND CMAKE_PREFIX_PATH /usr/local)
include_directories(
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/include/docopt"
)
add_library(dublintraceroute SHARED
@@ -40,14 +39,7 @@ endif (${libtins_FOUND})
pkg_search_module(JSONCPP REQUIRED jsoncpp)
add_executable(dublin-traceroute
src/main.cc
src/docopt/docopt.cpp
include/docopt/docopt.h
include/docopt/docopt_private.h
include/docopt/docopt_util.h
include/docopt/docopt_value.h
)
add_executable(dublin-traceroute src/main.cc)
target_link_libraries(dublintraceroute ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(dublin-traceroute dublintraceroute)
target_link_libraries(dublintraceroute tins)
View
@@ -1,88 +0,0 @@
//
// docopt.h
// docopt
//
// Created by Jared Grubb on 2013-11-03.
// Copyright (c) 2013 Jared Grubb. All rights reserved.
//
#ifndef docopt__docopt_h_
#define docopt__docopt_h_
#include "docopt_value.h"
#include <map>
#include <vector>
#include <string>
#ifdef DOCOPT_HEADER_ONLY
#define DOCOPT_INLINE inline
#define DOCOPTAPI
#else
#define DOCOPT_INLINE
// On Windows, export certain symbols so they are available
// to users of docopt.dll (shared library).
#ifdef WIN32
#ifdef DOCOPT_EXPORTS
#define DOCOPTAPI __declspec(dllexport)
#else
#define DOCOPTAPI __declspec(dllimport)
#endif
#else
#define DOCOPTAPI
#endif
#endif
namespace docopt {
// Usage string could not be parsed (ie, the developer did something wrong)
struct DocoptLanguageError : std::runtime_error { using runtime_error::runtime_error; };
// Arguments passed by user were incorrect (ie, developer was good, user is wrong)
struct DocoptArgumentError : std::runtime_error { using runtime_error::runtime_error; };
// Arguments contained '--help' and parsing was aborted early
struct DocoptExitHelp : std::runtime_error { DocoptExitHelp() : std::runtime_error("Docopt --help argument encountered"){} };
// Arguments contained '--version' and parsing was aborted early
struct DocoptExitVersion : std::runtime_error { DocoptExitVersion() : std::runtime_error("Docopt --version argument encountered") {} };
/// Parse user options from the given option string.
///
/// @param doc The usage string
/// @param argv The user-supplied arguments
/// @param help Whether to end early if '-h' or '--help' is in the argv
/// @param version Whether to end early if '--version' is in the argv
/// @param options_first Whether options must precede all args (true), or if args and options
/// can be arbitrarily mixed.
///
/// @throws DocoptLanguageError if the doc usage string had errors itself
/// @throws DocoptExitHelp if 'help' is true and the user has passed the '--help' argument
/// @throws DocoptExitVersion if 'version' is true and the user has passed the '--version' argument
/// @throws DocoptArgumentError if the user's argv did not match the usage patterns
std::map<std::string, value> DOCOPTAPI docopt_parse(std::string const& doc,
std::vector<std::string> const& argv,
bool help = true,
bool version = true,
bool options_first = false);
/// Parse user options from the given string, and exit appropriately
///
/// Calls 'docopt_parse' and will terminate the program if any of the exceptions above occur:
/// * DocoptLanguageError - print error and terminate (with exit code -1)
/// * DocoptExitHelp - print usage string and terminate (with exit code 0)
/// * DocoptExitVersion - print version and terminate (with exit code 0)
/// * DocoptArgumentError - print error and usage string and terminate (with exit code -1)
std::map<std::string, value> DOCOPTAPI docopt(std::string const& doc,
std::vector<std::string> const& argv,
bool help = true,
std::string const& version = {},
bool options_first = false) noexcept;
}
#ifdef DOCOPT_HEADER_ONLY
#include "docopt.cpp"
#endif
#endif /* defined(docopt__docopt_h_) */
Oops, something went wrong.

0 comments on commit 8a3ae75

Please sign in to comment.