3 * Copyright (c) 2020 Project CHIP Authors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * Source implementation of default shell commands for CHIP examples.
23 #include "CHIPVersion.h"
26 #include <support/CodeUtils.h>
38 int cmd_exit(int argc, char ** argv)
40 streamer_printf(streamer_get(), "Goodbye\n\r");
45 int cmd_help_iterator(shell_command_t * command, void * arg)
47 streamer_printf(streamer_get(), " %-15s %s\n\r", command->cmd_name, command->cmd_help);
51 int cmd_help(int argc, char ** argv)
53 shell_command_foreach(cmd_help_iterator, nullptr);
57 int cmd_version(int argc, char ** argv)
59 streamer_printf(streamer_get(), "CHIP %s\n\r", CHIP_VERSION_STRING);
63 static shell_command_t cmds[] = {
64 { &cmd_exit, "exit", "Exit the shell application" },
65 { &cmd_help, "help", "List out all top level commands" },
66 { &cmd_version, "version", "Output the software version" },
69 void Shell::RegisterDefaultCommands()
71 RegisterCommands(cmds, ArraySize(cmds));