From 6658ca8453d5012d1aef2be92d656641e425bf3a Mon Sep 17 00:00:00 2001 From: Mesut Tasci Date: Thu, 11 Jul 2019 22:06:59 +0300 Subject: [PATCH] banner added, only-found flag added --- main.go | 54 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/main.go b/main.go index d8a00bd..f25aa5f 100644 --- a/main.go +++ b/main.go @@ -9,36 +9,37 @@ import ( ) func main() { - // var wg sync.WaitGroup - // username := *flag.String("username", "", "One or more usernames to check with social networks.") - /* onlyFound := *flag.Bool("found", false, "Prints only found messages. Errors, and invalid username errors will not appear.") - flag.Parse() + var filterOnlyFounds bool - if flag.NArg() == 0 { - printUsage() - os.Exit(1) - } - - username := flag.Args()[0] - */ - - onlyFound := false var rootCmd = &cobra.Command{ Use: "sharlock", Short: "Find usernames across social networks", Args: cobra.MinimumNArgs(1), Example: "sherlock mesuutt", Run: func(cmd *cobra.Command, args []string) { - checker := newChecker(args[0], &sites) + username := args[0] + checker := newChecker(username, &sites) go checker.Check() cyan := color.New(color.FgCyan).SprintFunc() boldCyan := color.New(color.FgCyan).Add(color.Bold).SprintFunc() boldRed := color.New(color.FgRed).Add(color.Bold).SprintFunc() - bolGreen := color.New(color.FgGreen).Add(color.Bold).SprintFunc() + boldGreen := color.New(color.FgGreen).Add(color.Bold).SprintFunc() + boldWhite := color.New(color.FgWhite).Add(color.Bold).SprintFunc() + boldYellow := color.New(color.FgYellow).Add(color.Bold).SprintFunc() + + fmt.Printf( + "%s%s%s %s %s %s\n", + boldGreen("["), + boldWhite("*"), + boldGreen("]"), + boldGreen("Checking username"), + boldWhite(username), + boldGreen("on:"), + ) for c := range checker.Results() { - if onlyFound && (c.failed || !c.found) { + if filterOnlyFounds && (c.failed || !c.found) { continue } @@ -46,19 +47,34 @@ func main() { fmt.Printf("[%s] %s: %s (%s)\n", boldCyan("?"), boldCyan(c.site.name), c.ProfileUrl(), cyan("Check failed")) } else { if c.found { - fmt.Printf("[%s] %s: %s\n", bolGreen("+"), bolGreen(c.site.name), c.ProfileUrl()) + fmt.Printf("[%s] %s: %s\n", boldGreen("+"), boldGreen(c.site.name), c.ProfileUrl()) } else { - fmt.Printf("[%s] %s: %s\n", boldRed("-"), boldRed(c.site.name), c.ProfileUrl()) + fmt.Printf("[%s] %s: %s\n", boldRed("-"), boldRed(c.site.name), boldYellow("Not Found!")) } } } - }, } + showBanner() + rootCmd.Flags().BoolVarP(&filterOnlyFounds, "only-found", "i", false, "Prints only found messages. Errors, and invalid username errors will not appear.") if err := rootCmd.Execute(); err != nil { fmt.Println(err) os.Exit(1) } } + +func showBanner() { + banner := ` + ."""-. + / \ + ____ _ _ _ | _..--'-. +/ ___|| |__ ___ _ __| | ___ ___| |__ >.` + "`" + `__.-""\;"` + "`" + ` +\___ \| '_ \ / _ \ '__| |/ _ \ / __| |/ / / /( ^\ + ___) | | | | __/ | | | (_) | (__| < '-` + "`" + `) =|-. +|____/|_| |_|\___|_| |_|\___/ \___|_|\_\ /` + "`" + `--.'--' \ .-. + .'` + "`" + `-._ ` + "`" + `.\ | J /` + + fmt.Printf("%v\n\n", banner) +}