wip: interactive
This commit is contained in:
3
Makefile
3
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
|
||||
|
||||
|
||||
18
main.go
18
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user