diff --git a/Makefile b/Makefile index 00f35c7..4c6c509 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,9 @@ default: build build: $(CC) +run: + go run . + arm: env CGO_ENABLED=1 GOOS=linux GOARCH=arm64 $(CC) -o $(NAME)-arm64 diff --git a/main.go b/main.go index 73e0fbe..31af3c2 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( + "bufio" "context" "fmt" "log" @@ -86,6 +87,19 @@ func main() { //var dbLog waLog.Logger cmd := &cli.Command{ Usage: "Run WhatsApp actions from your CLI. User JID has to end with '@s.whatsapp.net', Group ID with '@g.us'", + Action: func(ctx context.Context, cmd *cli.Command) error { + fmt.Println("No command specified. Reading from stdin. Press Ctrl+D to exit or run with --help to get help.") + scanner := bufio.NewScanner(os.Stdin) + for scanner.Scan() { + // You can process each line from stdin here + fmt.Println("Received from stdin:", scanner.Text()) + if err := scanner.Err(); err != nil { + fmt.Print(err) + } + } + fmt.Println("Stdin closed.") + return nil + }, Commands: []*cli.Command{ { Name: "message", @@ -164,7 +178,5 @@ func main() { return nil }, } - if err := cmd.Run(context.Background(), os.Args); err != nil { - log.Fatal(err) - } + cmd.Run(context.Background(), os.Args) }