From 64eb854f29b25d8b06f5beccc3ed88ae0c0bc0a0 Mon Sep 17 00:00:00 2001 From: Jason Benaim Date: Mon, 10 Sep 2018 15:19:42 -0700 Subject: [PATCH] Print usage when argc is wrong --- hs100.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hs100.c b/hs100.c index db4bed0..ce6f703 100644 --- a/hs100.c +++ b/hs100.c @@ -4,6 +4,11 @@ #include #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 { char *alias; char *command; @@ -37,6 +42,10 @@ char *get_cmd(char *needle) int main(int argc, char *argv[]) { + if(argc != 3) { + fprintf(stderr, "%s", usage); + return 1; + } char *plug_addr = argv[1]; char *cmd = argv[2];