fix: publish
This commit is contained in:
@@ -2,6 +2,9 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"exporter/config"
|
||||
|
||||
"github.com/gotd/td/tg"
|
||||
"github.com/pkg/errors"
|
||||
@@ -18,7 +21,12 @@ func ExportCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "export",
|
||||
Short: "export channels",
|
||||
RunE: wrapE(exportCmd),
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("init client")
|
||||
defer fmt.Println("init client done")
|
||||
return InitClient(config.C)
|
||||
},
|
||||
RunE: wrapE(exportCmd),
|
||||
}
|
||||
|
||||
cmd.Flags().Int64Var(&channelID, "channel", 0, "channel id")
|
||||
|
||||
@@ -2,6 +2,9 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"exporter/config"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -10,6 +13,11 @@ func LoginCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "login",
|
||||
Short: "login account",
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("init client")
|
||||
defer fmt.Println("init client done")
|
||||
return InitClient(config.C)
|
||||
},
|
||||
RunE: wrapE(func(ctx context.Context) error {
|
||||
return client.Login(ctx)
|
||||
}),
|
||||
|
||||
@@ -21,7 +21,9 @@ func PublishCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "publish",
|
||||
Short: "publish posts",
|
||||
RunE: wrapE(publishCmd),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return publishCmd(context.Background())
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
|
||||
@@ -2,8 +2,10 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"exporter/config"
|
||||
"exporter/database/telegram_resource/public/model"
|
||||
"exporter/database/telegram_resource/public/table"
|
||||
"exporter/pkg/errorx"
|
||||
@@ -17,7 +19,12 @@ func WatchCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "watch",
|
||||
Short: "watch channels",
|
||||
RunE: wrapE(watchCmd),
|
||||
PreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("init client")
|
||||
defer fmt.Println("init client done")
|
||||
return InitClient(config.C)
|
||||
},
|
||||
RunE: wrapE(watchCmd),
|
||||
}
|
||||
|
||||
return cmd
|
||||
|
||||
5
main.go
5
main.go
@@ -27,10 +27,7 @@ func main() {
|
||||
if err := internal.InitDB(config.C.DSN); err != nil {
|
||||
return errors.Wrap(err, "init db")
|
||||
}
|
||||
|
||||
fmt.Println("init client")
|
||||
defer fmt.Println("init client done")
|
||||
return internal.InitClient(config.C)
|
||||
return nil
|
||||
},
|
||||
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Println("client exit")
|
||||
|
||||
Reference in New Issue
Block a user