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