summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pmain.cpp
blob: fb428a179fa664abefcaf7354daab112480b0f3c (plain) (blame)
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
41
42
43
44
45
46
47
// license:GPL-2.0+
// copyright-holders:Couriersud

#include "pmain.h"

namespace plib {

	app::app()
	: pout(&std::cout)
	, perr(&std::cerr)
	{

	}

	int app::main_utfX(const std::vector<putf8string> &argv)
	{
		auto r = this->parse(argv);

		if (r != argv.size())
		{
			this->perr("Error parsing {}\n", argv[r]);
			this->perr(this->usage_short());
			return 1;
		}

		return this->execute();
	}

	int app::main_utfX(int argc, char *argv[])
	{
		std::vector<putf8string> arg;
		for (std::size_t i = 0; i < narrow_cast<std::size_t>(argc); i++)
			arg.emplace_back(putf8string(argv[i]));

		return main_utfX(arg);
	}

	int app::main_utfX(int argc, wchar_t *argv[])
	{
		std::vector<putf8string> arg;
		for (std::size_t i = 0; i < narrow_cast<std::size_t>(argc); i++)
			arg.emplace_back(putf8string(pwstring(argv[i])));

		return main_utfX(arg);
	}

} // namespace plib