1
0
mirror of https://github.com/taigrr/tplinkController synced 2025-01-18 04:43:13 -08:00

Print usage when argc is wrong

This commit is contained in:
Jason Benaim 2018-09-10 15:19:42 -07:00
parent ff327294a4
commit 64eb854f29

View File

@ -4,6 +4,11 @@
#include <string.h> #include <string.h>
#include "comms.h" #include "comms.h"
const char usage[] =
"usage: hs100 ip command-or-json\n"
"where 'ip' is an IP address (ex. 192.168.1.1)\n"
"and 'command' is one of the words 'on', 'off', or a blob of json\n";
struct cmd_alias_s { struct cmd_alias_s {
char *alias; char *alias;
char *command; char *command;
@ -37,6 +42,10 @@ char *get_cmd(char *needle)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if(argc != 3) {
fprintf(stderr, "%s", usage);
return 1;
}
char *plug_addr = argv[1]; char *plug_addr = argv[1];
char *cmd = argv[2]; char *cmd = argv[2];