github.com/core-coin/go-core/v2@v2.1.9/cmd/xcbkey/main.go (about)

     1  // Copyright 2023 by the Authors
     2  // This file is part of go-core.
     3  //
     4  // go-core 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  // go-core 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 go-core. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package main
    18  
    19  import (
    20  	"fmt"
    21  	"os"
    22  
    23  	"gopkg.in/urfave/cli.v1"
    24  
    25  	"github.com/core-coin/go-core/v2/internal/flags"
    26  )
    27  
    28  const (
    29  	defaultKeyfileName = "keyfile.json"
    30  )
    31  
    32  // Git SHA1 commit hash of the release (set via linker flags)
    33  var gitTag = ""
    34  var gitCommit = ""
    35  var gitDate = ""
    36  
    37  var app *cli.App
    38  
    39  func init() {
    40  	app = flags.NewApp(gitTag, gitCommit, gitDate, "an Core key manager")
    41  	app.Commands = []cli.Command{
    42  		commandGenerate,
    43  		commandInspect,
    44  		commandChangePassphrase,
    45  		commandSignMessage,
    46  		commandVerifyMessage,
    47  	}
    48  	cli.CommandHelpTemplate = flags.OriginCommandHelpTemplate
    49  }
    50  
    51  // Commonly used command line flags.
    52  var (
    53  	passphraseFlag = cli.StringFlag{
    54  		Name:  "passwordfile",
    55  		Usage: "the file that contains the password for the keyfile",
    56  	}
    57  	jsonFlag = cli.BoolFlag{
    58  		Name:  "json",
    59  		Usage: "output JSON instead of human-readable format",
    60  	}
    61  )
    62  
    63  func main() {
    64  	if err := app.Run(os.Args); err != nil {
    65  		fmt.Fprintln(os.Stderr, err)
    66  		os.Exit(1)
    67  	}
    68  }