github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/cmd/receipts.go (about) 1 // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 // Use of this source code is governed by a license that can 3 // be found in the LICENSE file. 4 /* 5 * Parts of this file were auto generated. Edit only those parts of 6 * the code inside of 'EXISTING_CODE' tags. 7 */ 8 9 package cmd 10 11 // EXISTING_CODE 12 import ( 13 "os" 14 15 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/internal/globals" 16 receiptsPkg "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/internal/receipts" 17 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/caps" 18 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" 19 outputHelpers "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output/helpers" 20 "github.com/spf13/cobra" 21 ) 22 23 // EXISTING_CODE 24 25 // receiptsCmd represents the receipts command 26 var receiptsCmd = &cobra.Command{ 27 Use: usageReceipts, 28 Long: longReceipts, 29 Version: versionText, 30 PreRun: outputHelpers.PreRunWithJsonWriter("receipts", func() *globals.GlobalOptions { 31 return &receiptsPkg.GetOptions().Globals 32 }), 33 RunE: file.RunWithFileSupport("receipts", receiptsPkg.RunReceipts, receiptsPkg.ResetOptions), 34 PostRun: outputHelpers.PostRunWithJsonWriter(func() *globals.GlobalOptions { 35 return &receiptsPkg.GetOptions().Globals 36 }), 37 } 38 39 const usageReceipts = `receipts [flags] <tx_id> [tx_id...] 40 41 Arguments: 42 transactions - a space-separated list of one or more transaction identifiers (required)` 43 44 const longReceipts = `Purpose: 45 Retrieve receipts for the given transaction(s).` 46 47 const notesReceipts = ` 48 Notes: 49 - The transactions list may be one or more transaction hashes, blockNumber.transactionID pairs, or a blockHash.transactionID pairs. 50 - This tool checks for valid input syntax, but does not check that the transaction requested actually exists. 51 - If the queried node does not store historical state, the results for most older transactions are undefined.` 52 53 func init() { 54 var capabilities caps.Capability // capabilities for chifra receipts 55 capabilities = capabilities.Add(caps.Default) 56 capabilities = capabilities.Add(caps.Caching) 57 58 receiptsCmd.Flags().SortFlags = false 59 60 receiptsCmd.Flags().BoolVarP(&receiptsPkg.GetOptions().Articulate, "articulate", "a", false, `articulate the retrieved data if ABIs can be found`) 61 globals.InitGlobals("receipts", receiptsCmd, &receiptsPkg.GetOptions().Globals, capabilities) 62 63 receiptsCmd.SetUsageTemplate(UsageWithNotes(notesReceipts)) 64 receiptsCmd.SetOut(os.Stderr) 65 66 // EXISTING_CODE 67 // EXISTING_CODE 68 69 chifraCmd.AddCommand(receiptsCmd) 70 }