mirror of
https://github.com/anotherhadi/github-recon.git
synced 2026-10-05 19:08:24 +02:00
Init v2, rewrite
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package github_recon_settings
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
func getToken() string {
|
||||
token := os.Getenv("GITHUB_RECON_TOKEN")
|
||||
if token != "" {
|
||||
return token
|
||||
}
|
||||
|
||||
// Check the $HOME/.config/github-recon/env file for this variable
|
||||
homedir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "null"
|
||||
}
|
||||
godotenv.Load(filepath.Join(homedir, ".config/github-recon/env"))
|
||||
token = os.Getenv("GITHUB_RECON_TOKEN")
|
||||
if token != "" {
|
||||
return token
|
||||
}
|
||||
|
||||
return "null"
|
||||
}
|
||||
|
||||
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