blob: b3eb74c32b0f0e3c9b2b65849733bc667c9d023f [file] [log] [blame]
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package main
import (
"io"
"os"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/apache/skywalking-swck/pkg/build"
)
const (
cliName = "swck-build-tool"
)
func main() {
//The verbose flag value
var v string
cmd := &cobra.Command{
Short: cliName,
Long: "SWCK build tool chain",
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if err := setUpLogs(os.Stdout, v); err != nil {
return err
}
return nil
},
}
cmd.PersistentFlags().StringVarP(&v, "verbosity", "v", logrus.InfoLevel.String(), "Log level (debug, info, warn, error, fatal, panic")
cmd.Use = cliName
cmd.AddCommand(build.NewLicense())
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}
//setUpLogs set the log output ans the log level
func setUpLogs(out io.Writer, level string) error {
logrus.SetOutput(out)
lvl, err := logrus.ParseLevel(level)
if err != nil {
return err
}
logrus.SetLevel(lvl)
return nil
}