mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-02 21:53:51 +00:00
Style updates
This commit is contained in:
parent
6d26440b6e
commit
8cdf1c8651
@ -18,9 +18,7 @@ void setup_subcommand_a( CLI::App& app ) {
|
|||||||
sub->add_flag("--with-foo", opt->with_foo, "Counter");
|
sub->add_flag("--with-foo", opt->with_foo, "Counter");
|
||||||
|
|
||||||
// Set the run function as callback to be called when this subcommand is issued.
|
// Set the run function as callback to be called when this subcommand is issued.
|
||||||
sub->set_callback([opt]() {
|
sub->set_callback([opt]() { run_subcommand_a(*opt); });
|
||||||
run_subcommand_a( *opt );
|
|
||||||
});
|
|
||||||
|
|
||||||
// Note: In C++14, you could make a unique pointer, then pass it into the lambda function via
|
// Note: In C++14, you could make a unique pointer, then pass it into the lambda function via
|
||||||
// a move. That's slightly more elegant, but you won't be able to see the runtime difference
|
// a move. That's slightly more elegant, but you won't be able to see the runtime difference
|
||||||
@ -30,8 +28,7 @@ void setup_subcommand_a( CLI::App& app ) {
|
|||||||
/// The function that runs our code.
|
/// The function that runs our code.
|
||||||
/// This could also simply be in the callback lambda itself,
|
/// This could also simply be in the callback lambda itself,
|
||||||
/// but having a separate function is cleaner.
|
/// but having a separate function is cleaner.
|
||||||
void run_subcommand_a( SubcommandAOptions const& opt )
|
void run_subcommand_a(SubcommandAOptions const &opt) {
|
||||||
{
|
|
||||||
// Do stuff...
|
// Do stuff...
|
||||||
std::cout << "Working on file: " << opt.file << std::endl;
|
std::cout << "Working on file: " << opt.file << std::endl;
|
||||||
if(opt.with_foo) {
|
if(opt.with_foo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user