github.com/MetalBlockchain/subnet-evm@v0.4.9/plugin/params.go (about)

     1  // (c) 2019-2020, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package main
     5  
     6  import (
     7  	"flag"
     8  
     9  	"github.com/spf13/pflag"
    10  	"github.com/spf13/viper"
    11  )
    12  
    13  func subnetEVMFlagSet() *flag.FlagSet {
    14  	fs := flag.NewFlagSet("subnet-evm", flag.ContinueOnError)
    15  
    16  	fs.Bool(versionKey, false, "If true, print version and quit")
    17  
    18  	return fs
    19  }
    20  
    21  // getViper returns the viper environment for the plugin binary
    22  func getViper() (*viper.Viper, error) {
    23  	v := viper.New()
    24  
    25  	fs := subnetEVMFlagSet()
    26  	pflag.CommandLine.AddGoFlagSet(fs)
    27  	pflag.Parse()
    28  	if err := v.BindPFlags(pflag.CommandLine); err != nil {
    29  		return nil, err
    30  	}
    31  
    32  	return v, nil
    33  }
    34  
    35  func PrintVersion() (bool, error) {
    36  	v, err := getViper()
    37  	if err != nil {
    38  		return false, err
    39  	}
    40  
    41  	if v.GetBool(versionKey) {
    42  		return true, nil
    43  	}
    44  	return false, nil
    45  }