terminal: get rid of ctx.argc

No need to duplicate argv::size()
This commit is contained in:
Maxim Prokhorov
2021-12-08 17:38:04 +03:00
parent f2a7dcffe1
commit a0e090489b
22 changed files with 51 additions and 55 deletions

View File

@@ -2379,7 +2379,7 @@ namespace {
void _lightInitCommands() {
terminalRegisterCommand(F("LIGHT"), [](const terminal::CommandContext& ctx) {
if (ctx.argc > 1) {
if (ctx.argv.size() > 1) {
if (!_lightParsePayload(ctx.argv[1].c_str())) {
terminalError(ctx, F("Invalid payload"));
return;
@@ -2392,7 +2392,7 @@ void _lightInitCommands() {
});
terminalRegisterCommand(F("BRIGHTNESS"), [](const terminal::CommandContext& ctx) {
if (ctx.argc > 1) {
if (ctx.argv.size() > 1) {
_lightAdjustBrightness(ctx.argv[1]);
lightUpdate();
}
@@ -2416,7 +2416,7 @@ void _lightInitCommands() {
String(_light_channels[channel].current, 2).c_str());
};
if (ctx.argc > 2) {
if (ctx.argv.size() > 2) {
size_t id;
if (!_lightTryParseChannel(ctx.argv[1].c_str(), id)) {
terminalError(ctx, F("Invalid channel ID"));
@@ -2436,7 +2436,7 @@ void _lightInitCommands() {
});
terminalRegisterCommand(F("RGB"), [](const terminal::CommandContext& ctx) {
if (ctx.argc > 1) {
if (ctx.argv.size() > 1) {
_lightFromRgbPayload(ctx.argv[1].c_str());
lightUpdate();
}
@@ -2445,7 +2445,7 @@ void _lightInitCommands() {
});
terminalRegisterCommand(F("HSV"), [](const terminal::CommandContext& ctx) {
if (ctx.argc > 1) {
if (ctx.argv.size() > 1) {
_lightFromHsvPayload(ctx.argv[1].c_str());
lightUpdate();
}
@@ -2454,7 +2454,7 @@ void _lightInitCommands() {
});
terminalRegisterCommand(F("KELVIN"), [](const terminal::CommandContext& ctx) {
if (ctx.argc > 1) {
if (ctx.argv.size() > 1) {
_lightAdjustKelvin(ctx.argv[1]);
lightUpdate();
}
@@ -2463,7 +2463,7 @@ void _lightInitCommands() {
});
terminalRegisterCommand(F("MIRED"), [](const terminal::CommandContext& ctx) {
if (ctx.argc > 1) {
if (ctx.argv.size() > 1) {
_lightAdjustMireds(ctx.argv[1]);
lightUpdate();
}