github.com/decred/politeia@v1.4.0/politeiawww/cmd/cmswww/cmsusers.go (about) 1 // Copyright (c) 2017-2020 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 v1 "github.com/decred/politeia/politeiawww/api/cms/v1" 9 "github.com/decred/politeia/politeiawww/cmd/shared" 10 ) 11 12 // CMSUsersCmd retreives a list of users that have been filtered using the 13 // specified filtering params. 14 type CMSUsersCmd struct { 15 Domain int `long:"domain"` // Domain filter 16 ContractorType int `long:"contractortype"` // Contractor Type filter 17 } 18 19 // Execute executes the cmsusers command. 20 func (cmd *CMSUsersCmd) Execute(args []string) error { 21 u := v1.CMSUsers{ 22 Domain: v1.DomainTypeT(cmd.Domain), 23 ContractorType: v1.ContractorTypeT(cmd.ContractorType), 24 } 25 26 ur, err := client.CMSUsers(&u) 27 if err != nil { 28 return err 29 } 30 return shared.PrintJSON(ur) 31 } 32 33 // CMSUsersHelpMsg is the output of the help command when 'cmsusers' is specified. 34 const CMSUsersHelpMsg = `cmsusers [flags] 35 36 Fetch a list of cms users based on filters provided. 37 38 Arguments: None 39 40 Flags: 41 --domain (int, optional) Email filter 42 --contractortype (string, optional) Username filter 43 44 45 Example (Admin): 46 cmsusers --domain=1 --contractortype=1 47 48 Result : 49 { 50 "users": [ 51 { 52 "id": (string) User id 53 "domain": (string) Domaint Type 54 "username": (string) Username 55 "contractortype": (string) Contractor Type 56 } 57 ] 58 } 59 `