added flag and funcions to set default paths in the config file

This commit is contained in:
2021-05-09 04:27:32 +04:00
parent b36799f650
commit a1fd29ec45
3 changed files with 69 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"fmt"
"git.sr.ht/~akilan1999/p2p-rendering-computation/client"
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
"git.sr.ht/~akilan1999/p2p-rendering-computation/server"
"github.com/urfave/cli/v2"
@@ -17,7 +18,6 @@ var CliAction = func(ctx *cli.Context) error {
//Listing servers and also updates IP tables (Default 3 hops)
if UpdateServerList {
err := client.UpdateIpTableListClient()
if err != nil {
fmt.Print(err)
@@ -67,6 +67,14 @@ var CliAction = func(ctx *cli.Context) error {
client.PrettyPrint(specs)
}
//Sets default paths to the config file
if SetDefaultConfig {
err := config.SetDefaults()
if err != nil {
fmt.Print(err)
}
}
return nil
}

View File

@@ -15,6 +15,7 @@ var (
GPU bool
UpdateServerList bool
ServerList bool
SetDefaultConfig bool
)
var AppConfigFlags = []cli.Flag{
@@ -74,4 +75,10 @@ var AppConfigFlags = []cli.Flag{
EnvVars: []string{"SPECS"},
Destination: &Specs,
},
&cli.BoolFlag{
Name: "SetDefaultConfig",
Usage: "Sets a default configuration file",
EnvVars: []string{"SET_DEFAULT_CONFIG"},
Destination: &SetDefaultConfig,
},
}