public static CommandConfiguration SetFlag(this CommandConfiguration configuration, CommandConfigurationFlagTypes flag, bool isOn) { var hasFlag = configuration.HasFlag(flag); if (isOn && !hasFlag) { configuration.Flags |= flag; } else if (!isOn && hasFlag) { configuration.Flags &= flag; } return(configuration); }