github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/internal/status/validate.go (about) 1 // Copyright 2021 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 package statusPkg 6 7 import ( 8 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" 9 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/validate" 10 ) 11 12 func (opts *StatusOptions) validateStatus() error { 13 chain := opts.Globals.Chain 14 15 opts.testLog() 16 17 if opts.BadFlag != nil { 18 return opts.BadFlag 19 } 20 21 if !config.IsChainConfigured(chain) { 22 return validate.Usage("chain {0} is not properly configured.", chain) 23 } 24 25 options := `[index|blooms|blocks|transactions|traces|logs|statements|results|state|tokens|monitors|names|abis|slurps|staging|unripe|maps|some|all]` 26 err := validate.ValidateEnumSlice("mode", opts.Modes, options) 27 if err != nil { 28 return err 29 } 30 31 if opts.MaxRecords == 0 { 32 return validate.Usage("{0} must be greater than zero", "--max_records") 33 } 34 35 if len(opts.Modes) > 0 && opts.Diagnose { 36 return validate.Usage("{0} may not be used with {1}", "--diagnose", opts.Modes[0]) 37 } 38 39 if len(opts.Modes) == 0 && opts.Chains { 40 return validate.Usage("The {0} option is only available{1}.", "--chains", " with a mode") 41 } 42 43 return opts.Globals.Validate() 44 }