github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/cmd/commands/license/command.go (about) 1 /* 2 * Copyright (C) 2017 The "MysteriumNetwork/node" Authors. 3 * 4 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package license 19 20 import ( 21 "fmt" 22 23 "github.com/mysteriumnetwork/node/metadata" 24 "github.com/urfave/cli/v2" 25 ) 26 27 var ( 28 // FlagShowWarranty allows to print license warranty. 29 FlagShowWarranty = cli.BoolFlag{ 30 Name: "warranty", 31 Usage: "Show details of license warranty", 32 } 33 // FlagShowConditions allows to print license conditions. 34 FlagShowConditions = cli.BoolFlag{ 35 Name: "conditions", 36 Usage: "Show details of license conditions", 37 } 38 ) 39 40 // NewCommand function creates license command. 41 func NewCommand(licenseCopyright string) *cli.Command { 42 return &cli.Command{ 43 Name: "license", 44 Usage: "Show license", 45 ArgsUsage: " ", 46 Flags: []cli.Flag{&FlagShowWarranty, &FlagShowConditions}, 47 Action: func(ctx *cli.Context) error { 48 if ctx.Bool(FlagShowWarranty.Name) { 49 _, err := fmt.Fprintln(ctx.App.Writer, metadata.LicenseWarranty) 50 51 return err 52 } 53 54 if ctx.Bool(FlagShowConditions.Name) { 55 _, err := fmt.Fprintln(ctx.App.Writer, metadata.LicenseConditions) 56 57 return err 58 } 59 60 _, err := fmt.Fprintln(ctx.App.Writer, licenseCopyright) 61 62 return err 63 }, 64 } 65 }