Repository: microsoft/terminal
File: src/cascadia/TerminalApp/AppCommandlineArgs.cpp (C++)

Code before:
// - Additionally adds the `fp` subcommand, which is just a shortened version of `focus-pane`
// Arguments:
// - <none>
// Return Value:
// - <none>
void AppCommandlineArgs::_buildFocusPaneParser()
{
    _focusPaneCommand = _app.add_subcommand("focus-pane", RS_A(L"CmdFocusPaneDesc"));
    _focusPaneShort = _app.add_subcommand("fp", RS_A(L"CmdFPDesc"));

    auto setupSubcommand = [this](auto* subcommand) {
        auto* targetOpt = subcommand->add_option("-t,--target",
                                                 _focusPaneTarget,
                                                 RS_A(L"CmdFocusPaneTargetArgDesc"));
        targetOpt->required();
        targetOpt->check(CLI::NonNegativeNumber);
        // When ParseCommand is called, if this subcommand was provided, this
        // callback function will be triggered on the same thread. We can be sure
        // that `this` will still be safe - this function just lets us know this
        // command was parsed.
        subcommand->callback([&, this]() {
            // Build the action from the values we've parsed on the commandline.
            ActionAndArgs focusPaneAction{};

            if (_focusPaneTarget >= 0)
            {
                focusPaneAction.Action(ShortcutAction::FocusPane);
                FocusPaneArgs args{ static_cast<uint32_t>(_focusPaneTarget) };
                focusPaneAction.Args(args);
                _startupActions.push_back(focusPaneAction);
            }
        });
    };

    setupSubcommand(_focusPaneCommand);
    setupSubcommand(_focusPaneShort);
}

// Method Description:
// - Add the `NewTerminalArgs` parameters to the given subcommand. This enables
//   that subcommand to support all the properties in a NewTerminalArgs.
// Arguments:
// - subcommand: the command to add the args to.
// Return Value:
// - <none>
void AppCommandlineArgs::_addNewTerminalArgs(AppCommandlineArgs::NewTerminalSubcommand& subcommand)
{
    subcommand.profileNameOption = subcommand.subcommand->add_option("-p,--profile",
                                                                     _profileName,
                                                                     RS_A(L"CmdProfileArgDesc"));
    subcommand.startingDirectoryOption = subcommand.subcommand->add_option("-d,--startingDirectory",

Review comment (suggestion):
```suggestion
            if (_focusPaneTarget >= 0)
            {
                ActionAndArgs focusPaneAction{};
```

Code after:
// - Additionally adds the `fp` subcommand, which is just a shortened version of `focus-pane`
// Arguments:
// - <none>
// Return Value:
// - <none>
void AppCommandlineArgs::_buildFocusPaneParser()
{
    _focusPaneCommand = _app.add_subcommand("focus-pane", RS_A(L"CmdFocusPaneDesc"));
    _focusPaneShort = _app.add_subcommand("fp", RS_A(L"CmdFPDesc"));

    auto setupSubcommand = [this](auto* subcommand) {
        auto* targetOpt = subcommand->add_option("-t,--target",
                                                 _focusPaneTarget,
                                                 RS_A(L"CmdFocusPaneTargetArgDesc"));
        targetOpt->required();
        targetOpt->check(CLI::NonNegativeNumber);
        // When ParseCommand is called, if this subcommand was provided, this
        // callback function will be triggered on the same thread. We can be sure
        // that `this` will still be safe - this function just lets us know this
        // command was parsed.
        subcommand->callback([&, this]() {
            // Build the action from the values we've parsed on the commandline.
            if (_focusPaneTarget >= 0)
            {
                ActionAndArgs focusPaneAction{};
                focusPaneAction.Action(ShortcutAction::FocusPane);
                FocusPaneArgs args{ static_cast<uint32_t>(_focusPaneTarget) };
                focusPaneAction.Args(args);
                _startupActions.push_back(focusPaneAction);
            }
        });
    };

    setupSubcommand(_focusPaneCommand);
    setupSubcommand(_focusPaneShort);
}

// Method Description:
// - Add the `NewTerminalArgs` parameters to the given subcommand. This enables
//   that subcommand to support all the properties in a NewTerminalArgs.
// Arguments:
// - subcommand: the command to add the args to.
// Return Value:
// - <none>
void AppCommandlineArgs::_addNewTerminalArgs(AppCommandlineArgs::NewTerminalSubcommand& subcommand)
{
    subcommand.profileNameOption = subcommand.subcommand->add_option("-p,--profile",
                                                                     _profileName,
                                                                     RS_A(L"CmdProfileArgDesc"));
    subcommand.startingDirectoryOption = subcommand.subcommand->add_option("-d,--startingDirectory",
                                                                           _startingDirectory,