blob: 833f4fb56b63bb0ba00a2b115a22ad83dae68cd5 [file]
/*
*
* Copyright (c) 2026 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <lib/shell/Commands.h>
#include <lib/shell/Engine.h>
#include <lib/shell/commands/Help.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <string>
namespace chip {
namespace Shell {
class DeviceCommands
{
public:
// delete the copy constructor
DeviceCommands(const DeviceCommands &) = delete;
// delete the move constructor
DeviceCommands(DeviceCommands &&) = delete;
// delete the assignment operator
DeviceCommands & operator=(const DeviceCommands &) = delete;
static DeviceCommands & GetInstance()
{
static DeviceCommands instance;
return instance;
}
// Register the devtype commands
void Register();
private:
DeviceCommands() {}
static CHIP_ERROR DeviceHandler(int argc, char ** argv)
{
if (argc == 0)
{
sSubShell.ForEachCommand(PrintCommandHelp, nullptr);
return CHIP_NO_ERROR;
}
CHIP_ERROR error = sSubShell.ExecCommand(argc, argv);
if (error != CHIP_NO_ERROR)
{
streamer_printf(streamer_get(), "Error: %" CHIP_ERROR_FORMAT "\r\n", error.Format());
}
return error;
}
static CHIP_ERROR SetDeviceTypeHandler(int argc, char ** argv);
static CHIP_ERROR GetDeviceTypeHandler(int argc, char ** argv);
static CHIP_ERROR ListDeviceTypesHandler(int argc, char ** argv);
static Shell::Engine sSubShell;
};
} // namespace Shell
} // namespace chip