github.com/decred/politeia@v1.4.0/politeiawww/cmd/cmswww/userdetails.go (about) 1 // Copyright (c) 2017-2019 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 cms "github.com/decred/politeia/politeiawww/api/cms/v1" 9 "github.com/decred/politeia/politeiawww/cmd/shared" 10 ) 11 12 // UserDetailsCmd requests a user's information. 13 type UserDetailsCmd struct { 14 Args struct { 15 UserID string `positional-arg-name:"userid" optional:"true"` 16 } `positional-args:"true" optional:"true"` 17 } 18 19 // Execute executes the cms user information command. 20 func (cmd *UserDetailsCmd) Execute(args []string) error { 21 22 var uir *cms.UserDetailsReply 23 uid := cmd.Args.UserID 24 25 lr, err := client.Me() 26 if err != nil { 27 return err 28 } 29 30 if uid != "" { 31 uir, err = client.CMSUserDetails(uid) 32 } else { 33 uir, err = client.CMSUserDetails(lr.UserID) 34 } 35 if err != nil { 36 return err 37 } 38 39 // Print user information reply. 40 return shared.PrintJSON(uir) 41 } 42 43 // userDetailsHelpMsg is the output of the help command when 'userdetails' is 44 // specified. 45 const userDetailsHelpMsg = `userdetails "userid" 46 47 Fetch user details by user id. 48 49 Arguments: 50 1. userid (string, required) User id 51 `