-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcomplex_nesting.cpp
More file actions
78 lines (67 loc) · 2.39 KB
/
Copy pathcomplex_nesting.cpp
File metadata and controls
78 lines (67 loc) · 2.39 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*****************************************************************************
*
* demo program - part of CLIPP (command line interfaces for modern C++)
*
* released under MIT license
*
* (c) 2017-2018 André Müller; foss@andremueller-online.de
*
*****************************************************************************/
#include <iostream>
#include <string>
#include <vector>
#include <clipp.h>
int main(int argc, char* argv[])
{
using namespace clipp;
using std::cout;
using std::string;
auto copyMode = "copy mode:" % (
command("copy") | command("move"),
option("--all") % "copy all",
option("--replace") % "replace existing files",
option("-f", "--force") % "don't ask for confirmation"
);
auto compareMode = "compare mode:" % (
command("compare"),
(command("date") | command("content")),
option("-b", "--binary") % "compare files byte by byte",
option("-q", "--quick") % "use heuristics for faster comparison"
);
auto mergeAlgo = (
command("diff") % "merge using diff" |
command("patch") % "merge using patch" |
( command("content") % "merge based on content",
"content based merge options:" % (
option("--git-style") % "emulate git's merge behavior",
option("-m", "--marker") & value("marker") % "merge marker symbol"
)
)
);
auto mergeMode = "merge mode:" % (
command("merge"),
mergeAlgo,
required("-o") & value("outdir") % "target directory for merge result",
option("--show-conflicts") % "show merge conflicts during run"
);
auto firstOpt = "user interface options:" % (
option("-v", "--verbose") % "show detailed output",
option("-i", "--interactive") % "use interactive mode"
);
auto lastOpt = "mode-independent options:" % (
values("files") % "input files",
option("-r", "--recursive") % "descend into subdirectories",
option("-h", "--help") % "show help"
);
auto cli = (
firstOpt,
copyMode | compareMode | mergeMode | command("list"),
lastOpt
);
if(parse(argc, argv, cli)) {
// program logic...
} else {
auto fmt = doc_formatting{}.doc_column(31).last_column(80);
cout << make_man_page(cli, argv[0], fmt) << '\n';
}
}