Skip to content

Commit

Permalink
add search cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
li committed Nov 29, 2024
1 parent d510d73 commit f583fc9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func main() {
Commands: []*cli.Command{
appMeCmdCli,
userCmdCli,
searchUserCmdCli,
getUsersCmdCli,
transferCmdCli,
verifyPINCmdCli,
Expand Down
42 changes: 42 additions & 0 deletions cli/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,45 @@ func getUsersCmd(ctx *cli.Context) error {
}
return nil
}

var searchUserCmdCli = &cli.Command{
Name: "search",
Action: searchUserCmd,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "keystore,k",
Usage: "keystore download from https://developers.mixin.one/dashboard",
},
&cli.StringFlag{
Name: "id",
Usage: "user id",
},
},
}

func searchUserCmd(ctx *cli.Context) error {
keystore := ctx.String("keystore")
id := ctx.String("id")

dat, err := os.ReadFile(keystore)
if err != nil {
panic(err)
}
var su bot.SafeUser
err = json.Unmarshal([]byte(dat), &su)
if err != nil {
panic(err)
}

user, err := bot.SearchUser(context.Background(), id, &su)
if err != nil {
panic(err)
}
data, err := json.MarshalIndent(user, "", " ")
if err != nil {
panic(err)
}
logger := log.New(os.Stdout, "", 0)
logger.Println(string(data))
return nil
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/MixinNetwork/bot-api-go-client/v3

go 1.23.2
go 1.23.3

require (
filippo.io/edwards25519 v1.1.0
github.com/MixinNetwork/go-number v0.1.1
Expand Down

0 comments on commit f583fc9

Please sign in to comment.