blob: bb691ab3fe5c8ece706a43282fdfcb749366c765 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package main
import (
"context"
"flag"
"os"
"runtime/pprof"
"syscall"
"go.fuchsia.dev/fuchsia/tools/lib/color"
"go.fuchsia.dev/fuchsia/tools/lib/command"
"go.fuchsia.dev/fuchsia/tools/lib/logger"
"github.com/google/subcommands"
)
var (
colors color.EnableColor
level logger.LogLevel
)
func init() {
colors = color.ColorAuto
level = logger.DebugLevel
flag.Var(&colors, "color", "use color in output, can be never, auto, always")
flag.Var(&level, "level", "output verbosity, can be fatal, error, warning, info, debug or trace")
}
func main() {
subcommands.Register(subcommands.HelpCommand(), "")
subcommands.Register(subcommands.FlagsCommand(), "")
subcommands.Register(&upCommand{}, "")
flag.Parse()
log := logger.NewLogger(level, color.NewColor(colors), os.Stdout, os.Stderr, "artifactory ")
ctx := logger.WithLogger(context.Background(), log)
ctx = command.CancelOnSignals(ctx, syscall.SIGTERM)
go func() {
<-ctx.Done()
pprof.Lookup("goroutine").WriteTo(os.Stderr, 1)
}()
os.Exit(int(subcommands.Execute(ctx)))
}