1
0
mirror of https://github.com/yorukot/superfile.git synced 2025-02-06 09:26:18 +00:00

feat: -config-file flag support

This commit is contained in:
Harsh Bhagat 2025-02-05 21:16:11 +05:30
parent b5965dcb90
commit b89301a440

View File

@ -66,6 +66,12 @@ func Run(content embed.FS) {
Usage: "Print the last dir to stdout on exit (to use for cd)",
Value: false,
},
&cli.StringFlag{
Name: "config-file",
Aliases: []string{"c"},
Usage: "Specify the path to a different config file",
Value: variable.ConfigFile, // Default to the existing config file path
},
},
Action: func(c *cli.Context) error {
// If no args are called along with "spf" use current dir
@ -74,6 +80,14 @@ func Run(content embed.FS) {
path = c.Args().First()
}
// Setting the config file path
variable.ConfigFile = c.String("config-file")
// Validate the config file exists
if _, err := os.Stat(variable.ConfigFile); os.IsNotExist(err) {
log.Fatalf("Error: Configuration file '%s' does not exist", variable.ConfigFile)
}
InitConfigFile()
err := InitTrash()