github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/examples/ccchecker/main.go (about) 1 /* 2 Copyright IBM Corp. 2016 All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package main 18 19 import ( 20 "fmt" 21 "os" 22 23 "github.com/op/go-logging" 24 "github.com/spf13/cobra" 25 26 _ "net/http/pprof" 27 ) 28 29 var logger = logging.MustGetLogger("main") 30 31 // Constants go here. 32 const cmdRoot = "core" 33 34 // The main command describes the service and 35 // defaults to printing the help message. 36 var mainCmd = &cobra.Command{ 37 Use: "", 38 Run: func(cmd *cobra.Command, args []string) { 39 run(args) 40 }, 41 } 42 43 var orderingEndpoint string 44 45 func main() { 46 mainFlags := mainCmd.PersistentFlags() 47 mainFlags.StringVarP(&orderingEndpoint, "orderer", "o", "", "Ordering service endpoint") 48 //initialize the env 49 InitCCCheckerEnv(mainFlags) 50 51 // On failure Cobra prints the usage message and error string, so we only 52 // need to exit with a non-0 status 53 if mainCmd.Execute() != nil { 54 os.Exit(1) 55 } 56 } 57 58 func run(args []string) { 59 CCCheckerInit() 60 //TODO make parameters out of report and verbose 61 CCCheckerRun(orderingEndpoint, true, true) 62 fmt.Printf("Test complete\n") 63 return 64 }