github.com/ethereum/go-ethereum@v1.16.1/cmd/workload/main.go (about)

     1  // Copyright 2025 The go-ethereum Authors
     2  // This file is part of go-ethereum.
     3  //
     4  // go-ethereum 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-ethereum 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-ethereum. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package main
    18  
    19  import (
    20  	"fmt"
    21  	"os"
    22  
    23  	"github.com/ethereum/go-ethereum/internal/debug"
    24  	"github.com/ethereum/go-ethereum/internal/flags"
    25  	"github.com/urfave/cli/v2"
    26  )
    27  
    28  var app = flags.NewApp("go-ethereum workload test tool")
    29  
    30  func init() {
    31  	app.Flags = append(app.Flags, debug.Flags...)
    32  	app.Before = func(ctx *cli.Context) error {
    33  		flags.MigrateGlobalFlags(ctx)
    34  		return debug.Setup(ctx)
    35  	}
    36  	app.After = func(ctx *cli.Context) error {
    37  		debug.Exit()
    38  		return nil
    39  	}
    40  	app.CommandNotFound = func(ctx *cli.Context, cmd string) {
    41  		fmt.Fprintf(os.Stderr, "No such command: %s\n", cmd)
    42  		os.Exit(1)
    43  	}
    44  
    45  	// Add subcommands.
    46  	app.Commands = []*cli.Command{
    47  		runTestCommand,
    48  		historyGenerateCommand,
    49  		filterGenerateCommand,
    50  		traceGenerateCommand,
    51  		filterPerfCommand,
    52  	}
    53  }
    54  
    55  func main() {
    56  	exit(app.Run(os.Args))
    57  }
    58  
    59  func exit(err any) {
    60  	if err == nil {
    61  		os.Exit(0)
    62  	}
    63  	fmt.Fprintln(os.Stderr, err)
    64  	os.Exit(1)
    65  }