ekristen/gcp-nuke

View on GitHub
main.go

Summary

Maintainability
A
0 mins
Test Coverage
package main

import (
    "os"
    "path"

    "github.com/sirupsen/logrus"
    "github.com/urfave/cli/v2"

    "github.com/ekristen/gcp-nuke/pkg/common"

    _ "github.com/ekristen/gcp-nuke/pkg/commands/list"
    _ "github.com/ekristen/gcp-nuke/pkg/commands/project"
    _ "github.com/ekristen/gcp-nuke/pkg/commands/run"

    _ "github.com/ekristen/gcp-nuke/resources"
)

func main() {
    defer func() {
        if r := recover(); r != nil {
            // log panics forces exit
            if _, ok := r.(*logrus.Entry); ok {
                os.Exit(1)
            }
            panic(r)
        }
    }()

    app := cli.NewApp()
    app.Name = path.Base(os.Args[0])
    app.Usage = "remove everything from a GCP project"
    app.Version = common.AppVersion.Summary
    app.Authors = []*cli.Author{
        {
            Name:  "Erik Kristensen",
            Email: "erik@erikkristensen.com",
        },
    }

    app.Commands = common.GetCommands()
    app.CommandNotFound = func(context *cli.Context, command string) {
        logrus.Fatalf("command %s not found.", command)
    }

    if err := app.Run(os.Args); err != nil {
        logrus.Fatal(err)
    }
}