github.com/decred/politeia@v1.4.0/politeiawww/cmd/pictl/cmdproposalpolicy.go (about) 1 // Copyright (c) 2020-2021 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 pclient "github.com/decred/politeia/politeiawww/client" 9 ) 10 11 // cmdProposalPolicy retrieves the pi API policy. 12 type cmdProposalPolicy struct{} 13 14 // Execute executes the cmdProposalPolicy command. 15 // 16 // This function satisfies the go-flags Commander interface. 17 func (c *cmdProposalPolicy) Execute(args []string) error { 18 // Setup client 19 opts := pclient.Opts{ 20 HTTPSCert: cfg.HTTPSCert, 21 Verbose: cfg.Verbose, 22 RawJSON: cfg.RawJSON, 23 } 24 pc, err := pclient.New(cfg.Host, opts) 25 if err != nil { 26 return err 27 } 28 29 // Get policy 30 pr, err := pc.PiPolicy() 31 if err != nil { 32 return err 33 } 34 35 // Print policy 36 printJSON(pr) 37 38 return nil 39 } 40 41 // proposalEditHelpMsg is the printed to stdout by the help command. 42 const proposalPolicyHelpMsg = `proposalpolicy 43 44 Fetch the pi API policy.`