8
8
void show_usage (const pgm::args& args, std::string_view name);
9
9
void show_version (std::string_view name);
10
10
11
+ void transfer (std::string_view source, std::string_view dest);
12
+
11
13
int main (int argc, char * argv[])
12
14
try
13
15
{
33
35
};
34
36
35
37
std::exception_ptr ep;
36
- try { args.parse (argc, argv); }
37
- catch (...){ ep = std::current_exception (); }
38
+ try { args.parse (argc, argv); }
39
+ catch (...) { ep = std::current_exception (); }
38
40
39
- if (args[" --help" ])
41
+ if (args[" --help" ])
40
42
show_usage (args, name);
41
43
42
- else if (args[" --version" ])
44
+ else if (args[" --version" ])
43
45
show_version (name);
44
46
45
- else if (ep)
47
+ else if (ep)
46
48
std::rethrow_exception (ep);
47
49
48
50
else // normal program flow
55
57
auto copy_links = !!args[" -l" ];
56
58
auto deref_links = !!args[" -L" ];
57
59
58
- if (copy_links && deref_links) throw pgm::invalid_argument{
60
+ if (copy_links && deref_links) throw pgm::invalid_argument{
59
61
" options '-l' and '-L' are mutually exclusive"
60
62
};
61
63
62
64
auto chmod = args[" --chmod" ].value_or (" 0644" );
63
65
64
66
std::vector<std::string> rules;
65
- for (auto const & rule : args[" --filter" ].values ()) rules.push_back (rule);
67
+ for (auto const & rule : args[" --filter" ].values ()) rules.push_back (rule);
66
68
67
69
std::vector<std::string> sources;
68
- for (auto const & source : args[" SRC" ].values ()) sources.push_back (source);
70
+ for (auto const & source : args[" SRC" ].values ()) sources.push_back (source);
69
71
70
72
auto dest = args[" DEST" ].value ();
71
73
72
74
// "transfer" files
73
- for (auto const & source : sources)
75
+ for (auto const & source : sources)
74
76
{
75
- if (!quiet) std::cout << " Sending " << source << " to " << dest << std::endl;
77
+ if (!quiet) std::cout << " Sending " << source << " to " << dest << std::endl;
78
+ transfer (source, dest);
76
79
}
77
80
}
78
81
79
82
return 0 ;
80
83
}
81
- catch (const std::exception& e)
84
+ catch (const std::exception& e)
82
85
{
83
86
std::cerr << e.what () << std::endl;
84
87
return 1 ;
@@ -107,3 +110,8 @@ void show_version(std::string_view name)
107
110
{
108
111
std::cout << name << " 0.42" << std::endl;
109
112
}
113
+
114
+ void transfer (std::string_view source, std::string_view dest)
115
+ {
116
+ //
117
+ }
0 commit comments