mirror of
https://github.com/anotherhadi/github-recon.git
synced 2026-10-05 10:58:25 +02:00
@@ -11,15 +11,6 @@ import (
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func wordSepNormalizeFunc(f *flag.FlagSet, name string) flag.NormalizedName {
|
||||
from := []string{".", "_"}
|
||||
to := "-"
|
||||
for _, sep := range from {
|
||||
name = strings.ReplaceAll(name, sep, to)
|
||||
}
|
||||
return flag.NormalizedName(name)
|
||||
}
|
||||
|
||||
func main() {
|
||||
var username string
|
||||
var token string
|
||||
@@ -78,49 +69,38 @@ func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
styles := log.DefaultStyles()
|
||||
styles.Levels[log.InfoLevel] = styles.Levels[log.InfoLevel].Foreground(ghrecon.Grey)
|
||||
logger := log.NewWithOptions(os.Stderr, log.Options{
|
||||
r := &ghrecon.Recon{
|
||||
Client: github.NewClient(nil),
|
||||
Logger: log.NewWithOptions(os.Stderr, log.Options{
|
||||
ReportCaller: false,
|
||||
ReportTimestamp: false,
|
||||
})
|
||||
logger.SetStyles(styles)
|
||||
|
||||
if username == "" && fromEmail == "" {
|
||||
logger.Error(
|
||||
"Please provide a username with the --username (-u) flag or an email with the --email (-e) flag",
|
||||
)
|
||||
os.Exit(1)
|
||||
} else if username != "" {
|
||||
username = strings.TrimPrefix(username, "@")
|
||||
if err := ghrecon.ParseUsername(username); err != nil {
|
||||
logger.Error("Invalid username", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
client := github.NewClient(nil)
|
||||
if token == "" {
|
||||
if !silent {
|
||||
logger.Info(
|
||||
"It's recommended to set a Github token for better rate limits. You can set it using the --token (-t) flag.",
|
||||
)
|
||||
}
|
||||
} else {
|
||||
client = client.WithAuthToken(token)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
r := &ghrecon.Recon{
|
||||
Client: client,
|
||||
Logger: logger,
|
||||
Ctx: ctx,
|
||||
}),
|
||||
Ctx: context.Background(),
|
||||
Silent: silent,
|
||||
JsonFile: jsonFile,
|
||||
MaxRepoSize: maxRepoSize,
|
||||
}
|
||||
|
||||
if username == "" && fromEmail == "" {
|
||||
r.Logger.Fatal(
|
||||
"Please provide a username with the --username (-u) flag or an email with the --email (-e) flag",
|
||||
)
|
||||
} else if username != "" {
|
||||
username = strings.TrimPrefix(username, "@")
|
||||
if err := ghrecon.ParseUsername(username); err != nil {
|
||||
r.Logger.Fatal("Invalid username", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
if token == "" {
|
||||
r.PrintInfo(
|
||||
"INFO",
|
||||
"It's recommended to set a Github token for better rate limits. You can set it using the --token (-t) flag.",
|
||||
)
|
||||
} else {
|
||||
r.Client = r.Client.WithAuthToken(token)
|
||||
}
|
||||
|
||||
r.Header()
|
||||
|
||||
if fromEmail != "" {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func wordSepNormalizeFunc(f *flag.FlagSet, name string) flag.NormalizedName {
|
||||
from := []string{".", "_"}
|
||||
to := "-"
|
||||
for _, sep := range from {
|
||||
name = strings.ReplaceAll(name, sep, to)
|
||||
}
|
||||
return flag.NormalizedName(name)
|
||||
}
|
||||
Reference in New Issue
Block a user