Skip to content

Commit 4168251

Browse files
example2: formatting, add empty transfer() fn
1 parent ab8ca80 commit 4168251

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

example/example2.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
void show_usage(const pgm::args& args, std::string_view name);
99
void show_version(std::string_view name);
1010

11+
void transfer(std::string_view source, std::string_view dest);
12+
1113
int main(int argc, char* argv[])
1214
try
1315
{
@@ -33,16 +35,16 @@ try
3335
};
3436

3537
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(); }
3840

39-
if(args["--help"])
41+
if (args["--help"])
4042
show_usage(args, name);
4143

42-
else if(args["--version"])
44+
else if (args["--version"])
4345
show_version(name);
4446

45-
else if(ep)
47+
else if (ep)
4648
std::rethrow_exception(ep);
4749

4850
else // normal program flow
@@ -55,30 +57,31 @@ try
5557
auto copy_links = !!args["-l"];
5658
auto deref_links = !!args["-L"];
5759

58-
if(copy_links && deref_links) throw pgm::invalid_argument{
60+
if (copy_links && deref_links) throw pgm::invalid_argument{
5961
"options '-l' and '-L' are mutually exclusive"
6062
};
6163

6264
auto chmod = args["--chmod"].value_or("0644");
6365

6466
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);
6668

6769
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);
6971

7072
auto dest = args["DEST"].value();
7173

7274
// "transfer" files
73-
for(auto const& source : sources)
75+
for (auto const& source : sources)
7476
{
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);
7679
}
7780
}
7881

7982
return 0;
8083
}
81-
catch(const std::exception& e)
84+
catch (const std::exception& e)
8285
{
8386
std::cerr << e.what() << std::endl;
8487
return 1;
@@ -107,3 +110,8 @@ void show_version(std::string_view name)
107110
{
108111
std::cout << name << " 0.42" << std::endl;
109112
}
113+
114+
void transfer(std::string_view source, std::string_view dest)
115+
{
116+
//
117+
}

0 commit comments

Comments
 (0)