github.com/decred/politeia@v1.4.0/politeiawww/cmd/pictl/cmdrecordpolicy.go (about)

     1  // Copyright (c) 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  // cmdRecordPolicy retrieves the records API policy.
    12  type cmdRecordPolicy struct{}
    13  
    14  // Execute executes the cmdRecordPolicy command.
    15  //
    16  // This function satisfies the go-flags Commander interface.
    17  func (c *cmdRecordPolicy) 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.RecordPolicy()
    31  	if err != nil {
    32  		return err
    33  	}
    34  
    35  	// Print policy
    36  	printJSON(pr)
    37  
    38  	return nil
    39  }
    40  
    41  // recordPolicyHelpMsg is the printed to stdout by the help command.
    42  const recordPolicyHelpMsg = `recordpolicy
    43  
    44  Fetch the records API policy.`