1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

fix cafe cli

This commit is contained in:
Roman Khafizianov 2021-04-10 21:48:11 +04:00
parent 4eedd9e69f
commit 117cb4a29d
No known key found for this signature in database
GPG key ID: F07A7D55A2684852

View file

@ -2,15 +2,12 @@ package main
import (
"context"
"github.com/anytypeio/go-anytype-middleware/app"
"github.com/anytypeio/go-anytype-middleware/core/wallet"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/cafe"
"github.com/anytypeio/go-anytype-middleware/core/anytype"
coreService "github.com/anytypeio/go-anytype-middleware/pkg/lib/core"
"github.com/anytypeio/go-anytype-middleware/pkg/lib/profilefinder"
walletUtil "github.com/anytypeio/go-anytype-middleware/pkg/lib/wallet"
"github.com/anytypeio/go-anytype-middleware/util/console"
"github.com/spf13/cobra"
"io/ioutil"
"os"
)
var cafeCmd = &cobra.Command{
@ -53,14 +50,7 @@ var findProfiles = &cobra.Command{
// create temp walletUtil in order to do requests to cafe
appMnemonic, err = coreService.WalletGenerateMnemonic(12)
appAccount, err = coreService.WalletAccountAt(appMnemonic, 0, "")
rootPath, err := ioutil.TempDir(os.TempDir(), "anytype_*")
app := new(app.App)
app.Register(wallet.NewWithRepoPathAndKeys(rootPath, appAccount, nil))
app.Register(cafe.New())
at := coreService.New()
app.Register(at)
err = app.Start()
app, err := anytype.StartAccountRecoverApp(nil, appAccount)
if err != nil {
console.Fatal("failed to start anytype: %s", err.Error())
return
@ -79,7 +69,8 @@ var findProfiles = &cobra.Command{
console.Success("got profile: id=%s name=%s", profile.AccountAddr, profile.Name)
}
}()
err = at.FindProfilesByAccountIDs(context.Background(), accountsToFind, ch)
profileFinder := app.MustComponent(profilefinder.CName).(profilefinder.Service)
err = profileFinder.FindProfilesByAccountIDs(context.Background(), accountsToFind, ch)
if err != nil {
console.Fatal("failed to query cafe: " + err.Error())
}