gitlab.com/aquachain/aquachain@v1.17.16-rc3.0.20221018032414-e3ddf1e1c055/cmd/attacher/main.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  // aquachain is the official command-line client for Aquachain.
    18  package main
    19  
    20  import (
    21  	"fmt"
    22  	"os"
    23  	"sort"
    24  
    25  	cli "github.com/urfave/cli"
    26  	"gitlab.com/aquachain/aquachain/cmd/utils"
    27  	"gitlab.com/aquachain/aquachain/opt/console"
    28  )
    29  
    30  const (
    31  	clientIdentifier = "aquachain-lite" // Client identifier to advertise over the network
    32  )
    33  
    34  var (
    35  	// Git SHA1 commit hash and timestamp of the release (set via linker flags)
    36  	gitCommit, buildDate string
    37  	// The app that holds all commands and flags.
    38  	app = utils.NewApp(gitCommit, "the aquachain command line interface")
    39  )
    40  
    41  func init() {
    42  	// Initialize the CLI app and start Aquachain
    43  	//app.Action = app.Usage // default command is 'console'
    44  
    45  	app.HideVersion = true // we have a command to print the version
    46  	app.Copyright = "Copyright 2018-2019 The Aquachain Authors"
    47  	app.Commands = []cli.Command{
    48  		// See walletcmd.go
    49  		paperCommand,
    50  		// See consolecmd.go:
    51  		attachCommand,
    52  		// See misccmd.go:
    53  		versionCommand,
    54  		licenseCommand,
    55  	}
    56  	sort.Sort(cli.CommandsByName(app.Commands))
    57  
    58  	app.Flags = append(app.Flags, consoleFlags...)
    59  
    60  	app.Before = func(ctx *cli.Context) error {
    61  		return nil
    62  	}
    63  
    64  	app.After = func(ctx *cli.Context) error {
    65  		console.Stdin.Close() // Resets terminal mode.
    66  		return nil
    67  	}
    68  }
    69  
    70  func main() {
    71  	if err := app.Run(os.Args); err != nil {
    72  		fmt.Fprintln(os.Stderr, err)
    73  		os.Exit(1)
    74  	}
    75  }