wip: interactive
This commit is contained in:
3
Makefile
3
Makefile
@@ -5,6 +5,9 @@ default: build
|
|||||||
build:
|
build:
|
||||||
$(CC)
|
$(CC)
|
||||||
|
|
||||||
|
run:
|
||||||
|
go run .
|
||||||
|
|
||||||
arm:
|
arm:
|
||||||
env CGO_ENABLED=1 GOOS=linux GOARCH=arm64 $(CC) -o $(NAME)-arm64
|
env CGO_ENABLED=1 GOOS=linux GOARCH=arm64 $(CC) -o $(NAME)-arm64
|
||||||
|
|
||||||
|
|||||||
18
main.go
18
main.go
@@ -2,6 +2,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@@ -86,6 +87,19 @@ func main() {
|
|||||||
//var dbLog waLog.Logger
|
//var dbLog waLog.Logger
|
||||||
cmd := &cli.Command{
|
cmd := &cli.Command{
|
||||||
Usage: "Run WhatsApp actions from your CLI. User JID has to end with '@s.whatsapp.net', Group ID with '@g.us'",
|
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{
|
Commands: []*cli.Command{
|
||||||
{
|
{
|
||||||
Name: "message",
|
Name: "message",
|
||||||
@@ -164,7 +178,5 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if err := cmd.Run(context.Background(), os.Args); err != nil {
|
cmd.Run(context.Background(), os.Args)
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user