...

Source file src/edge-infra.dev/cmd/sds/etcd/manager/main.go

Documentation: edge-infra.dev/cmd/sds/etcd/manager

     1  package main
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"os"
     7  
     8  	ecli "edge-infra.dev/pkg/lib/cli"
     9  	"edge-infra.dev/pkg/lib/fog"
    10  	"edge-infra.dev/pkg/lib/runtime/version"
    11  	etcdmanager "edge-infra.dev/pkg/sds/etcd/manager"
    12  )
    13  
    14  func main() {
    15  	log := fog.New().WithName("etcd-manager")
    16  
    17  	if len(os.Args) < 2 {
    18  		err := fmt.Errorf("invalid arguments")
    19  		log.Error(err, "Usage: /app/cmd/sds/etcd/manager/etcdmanager_container.binary <subcommand> <args>")
    20  		os.Exit(1)
    21  	}
    22  
    23  	switch os.Args[1] {
    24  	// if the subcommand is help, print the usage and exit
    25  	case "help", "-h", "--help":
    26  		log.V(0).Info("Usage: /app/cmd/sds/etcd/manager/etcdmanager_container.binary <subcommand> <args>")
    27  	// if the subcommand is version, print the version and exit
    28  	case "version", "-v", "--version":
    29  		v := version.New()
    30  		buf := new(bytes.Buffer)
    31  		ecli.Version(buf, v)
    32  		log.V(0).Info(buf.String())
    33  	// if the subcommand is run, run the run command with the given arguments
    34  	case "run":
    35  		err := etcdmanager.Run()
    36  		log.Error(err, "error in etcdmanager run")
    37  		os.Exit(1)
    38  	// if the subcommand is anything else, print the usage and exit
    39  	default:
    40  		err := fmt.Errorf("invalid subcommand")
    41  		log.Error(err, "Usage: /app/cmd/sds/etcd/manager/etcdmanager_container.binary <subcommand> <args>", "subcommand", os.Args[1])
    42  		os.Exit(1)
    43  	}
    44  
    45  	os.Exit(0)
    46  }
    47  

View as plain text