gitlab.com/aquachain/aquachain@v1.17.16-rc3.0.20221018032414-e3ddf1e1c055/cmd/attacher/misccmd.go (about) 1 // Copyright 2019 The aquachain Authors 2 // This file is part of aquachain. 3 // 4 // aquachain is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // aquachain is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with aquachain. If not, see <http://www.gnu.org/licenses/>. 16 17 package main 18 19 import ( 20 "fmt" 21 "os" 22 "runtime" 23 "strconv" 24 "strings" 25 "time" 26 27 "github.com/urfave/cli" 28 "gitlab.com/aquachain/aquachain/aqua" 29 "gitlab.com/aquachain/aquachain/cmd/utils" 30 "gitlab.com/aquachain/aquachain/params" 31 ) 32 33 var ( 34 versionCommand = cli.Command{ 35 Action: utils.MigrateFlags(version), 36 Name: "version", 37 Usage: "Print version numbers", 38 ArgsUsage: " ", 39 Category: "MISCELLANEOUS COMMANDS", 40 Description: ` 41 The output of this command is supposed to be machine-readable. 42 `, 43 } 44 licenseCommand = cli.Command{ 45 Action: utils.MigrateFlags(license), 46 Name: "license", 47 Usage: "Display license information", 48 ArgsUsage: " ", 49 Category: "MISCELLANEOUS COMMANDS", 50 } 51 ) 52 53 func version(ctx *cli.Context) error { 54 fmt.Println(strings.Title(clientIdentifier)) 55 fmt.Println("Version:", params.Version) 56 if gitCommit != "" { 57 fmt.Println("Git Commit:", gitCommit) 58 } 59 if buildDate != "" { 60 ts, err := strconv.Atoi(buildDate) 61 if err == nil { 62 fmt.Printf("Build Date: %s UTC\n", time.Unix(int64(ts), 0).UTC().Format(time.ANSIC)) 63 } else { 64 fmt.Printf("WARN: tried to get date, but got err: %v\n", err) 65 } 66 } 67 fmt.Println("Architecture:", runtime.GOARCH) 68 fmt.Println("Protocol Versions:", aqua.ProtocolVersions) 69 fmt.Println("Network Id:", aqua.DefaultConfig.NetworkId) 70 fmt.Println("Go Version:", runtime.Version()) 71 fmt.Println("Operating System:", runtime.GOOS) 72 fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH")) 73 fmt.Printf("GOROOT=%s\n", runtime.GOROOT()) 74 fmt.Printf("Fork Map: %s\n", params.AquachainHF.String()) 75 return nil 76 } 77 78 func license(_ *cli.Context) error { 79 fmt.Println(`Aquachain is free software: you can redistribute it and/or modify 80 it under the terms of the GNU General Public License as published by 81 the Free Software Foundation, either version 3 of the License, or 82 (at your option) any later version. 83 84 Aquachain is distributed in the hope that it will be useful, 85 but WITHOUT ANY WARRANTY; without even the implied warranty of 86 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 87 GNU General Public License for more details. 88 89 You should have received a copy of the GNU General Public License 90 along with aquachain. If not, see <http://www.gnu.org/licenses/>.`) 91 return nil 92 }