File: run_testcase.cpp

package info (click to toggle)
docopt.cpp 0.6.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 236 kB
  • sloc: cpp: 1,502; python: 57; sh: 20; makefile: 13
file content (40 lines) | stat: -rw-r--r-- 751 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
//  docopt_tests.cpp
//  docopt
//
//  Created by Jared Grubb on 2013-11-03.
//  Copyright (c) 2013 Jared Grubb. All rights reserved.
//

#include "docopt.h"

#include <iostream>

int main(int argc, const char** argv)
{
	if (argc < 2) {
		std::cerr << "Usage: docopt_tests USAGE [arg]..." << std::endl;
		exit(-5);
	}
	
	std::string usage = argv[1];
	std::vector<std::string> args {argv+2, argv+argc};
	
	auto result = docopt::docopt(usage, args);

	// print it out in JSON form
	std::cout << "{ ";
	bool first = true;
	for(auto const& arg : result) {
		if (first) {
			first = false;
		} else {
			std::cout << "," << std::endl;
		}
		
		std::cout << '"' << arg.first << '"' << ": " << arg.second;
	}
	std::cout << " }" << std::endl;

	return 0;
}