mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-15 23:46:12 +00:00
Add 'config' flag
This commit is contained in:
+12
-10
@@ -22,20 +22,22 @@ var config = StormfetchConfig{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readConfig() {
|
func readConfig() {
|
||||||
// Get home directory
|
if ConfigPath == "" {
|
||||||
userConfigDir, _ := os.UserConfigDir()
|
// Get home directory
|
||||||
|
userConfigDir, _ := os.UserConfigDir()
|
||||||
|
|
||||||
// Find valid config directory
|
// Find valid config directory
|
||||||
if _, err := os.Stat(path.Join(userConfigDir, "stormfetch/config.yml")); err == nil {
|
if _, err := os.Stat(path.Join(userConfigDir, "stormfetch/config.yml")); err == nil {
|
||||||
configPath = path.Join(userConfigDir, "stormfetch/config.yml")
|
ConfigPath = path.Join(userConfigDir, "stormfetch/config.yml")
|
||||||
} else if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/config.yml")); err == nil {
|
} else if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/config.yml")); err == nil {
|
||||||
configPath = path.Join(SystemConfigDir, "stormfetch/config.yml")
|
ConfigPath = path.Join(SystemConfigDir, "stormfetch/config.yml")
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Config file not found: %s", err.Error())
|
log.Fatalf("Config file not found: %s", err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse config
|
// Parse config
|
||||||
bytes, err := os.ReadFile(configPath)
|
bytes, err := os.ReadFile(ConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -15,19 +15,19 @@ var SystemConfigDir = "/etc/"
|
|||||||
|
|
||||||
// Flag variables
|
// Flag variables
|
||||||
var ShowVersion = false
|
var ShowVersion = false
|
||||||
|
var ConfigPath = ""
|
||||||
var ShowModuleTimeTaken = false
|
var ShowModuleTimeTaken = false
|
||||||
|
|
||||||
var configPath = ""
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
readConfig()
|
|
||||||
parseFlags()
|
parseFlags()
|
||||||
|
readConfig()
|
||||||
initializeModuleMap()
|
initializeModuleMap()
|
||||||
run()
|
run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFlags() {
|
func parseFlags() {
|
||||||
flag.BoolVar(&ShowVersion, "version", false, "Show Stormfetch version")
|
flag.BoolVar(&ShowVersion, "version", false, "Show Stormfetch version")
|
||||||
|
flag.StringVar(&ConfigPath, "config", "", "Use the specified config file")
|
||||||
flag.BoolVar(&ShowModuleTimeTaken, "time-taken", false, "Show time taken to execute each module")
|
flag.BoolVar(&ShowModuleTimeTaken, "time-taken", false, "Show time taken to execute each module")
|
||||||
flag.StringVar(&config.Ascii, "ascii", config.Ascii, "Set distro ascii")
|
flag.StringVar(&config.Ascii, "ascii", config.Ascii, "Set distro ascii")
|
||||||
flag.StringVar(&config.DistroName, "distro-name", config.DistroName, "Set distro name")
|
flag.StringVar(&config.DistroName, "distro-name", config.DistroName, "Set distro name")
|
||||||
|
|||||||
Reference in New Issue
Block a user