Add cli banner

This commit is contained in:
abhisek 2023-01-18 12:27:16 +05:30
parent ce6c1b3395
commit a8bcb7a898
No known key found for this signature in database
GPG Key ID: CB92A4990C02A88F
2 changed files with 32 additions and 3 deletions

View File

@ -1,5 +1,5 @@
# vet : The dependency vetting tool
Tool for identifying software supply chain risks
# vet
Tool for identifying open source software supply chain risks
## TL;DR
@ -40,3 +40,9 @@ Insights API Key can be passed at runtime using environment variable
```bash
VET_INSIGHTS_API_KEY=... vet scan
```
## FAQ
### How do I disable the stupid banner?
Set environment variable `VET_DISABLE_BANNER=1`

25
main.go
View File

@ -3,6 +3,7 @@ package main
import (
"fmt"
"os"
"strconv"
"github.com/safedep/vet/pkg/common/logger"
"github.com/spf13/cobra"
@ -13,10 +14,24 @@ var (
debug bool
)
var banner string = `
.----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. |
| | ____ ____ | || | _________ | || | _________ | |
| ||_ _| |_ _| | || | |_ ___ | | || | | _ _ | | |
| | \ \ / / | || | | |_ \_| | || | |_/ | | \_| | |
| | \ \ / / | || | | _| _ | || | | | | |
| | \ ' / | || | _| |___/ | | || | _| |_ | |
| | \_/ | || | |_________| | || | |_____| | |
| | | || | | || | | |
| '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------'
`
func main() {
cmd := &cobra.Command{
Use: "vet [OPTIONS] COMMAND [ARG...]",
Short: "Vet your 3rd party dependencies for security risks",
Short: "[ Establish trust in open source software supply chain ]",
TraverseChildren: true,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
@ -35,6 +50,7 @@ func main() {
cmd.AddCommand(newVersionCommand())
cobra.OnInitialize(func() {
printBanner()
logger.SetLogLevel(verbose, debug)
})
@ -42,3 +58,10 @@ func main() {
os.Exit(1)
}
}
func printBanner() {
bRet, err := strconv.ParseBool(os.Getenv("VET_DISABLE_BANNER"))
if (err != nil) || (!bRet) {
fmt.Print(banner)
}
}