-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mainnet' into bug/apps-create-multiple-transports-248
- Loading branch information
Showing
28 changed files
with
2,473 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
.idea/ | ||
|
||
/skywire.json | ||
/skywire-config.json | ||
/manager-config.json | ||
/apps/ | ||
/skywire/ | ||
/local/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/skycoin/skywire/internal/pathutil" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/skycoin/skywire/pkg/manager" | ||
) | ||
|
||
var ( | ||
output string | ||
replace bool | ||
configLocType = pathutil.WorkingDirLoc | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(genConfigCmd) | ||
genConfigCmd.Flags().StringVarP(&output, "output", "o", "", "path of output config file. Uses default of 'type' flag if unspecified.") | ||
genConfigCmd.Flags().BoolVarP(&replace, "replace", "r", false, "whether to allow rewrite of a file that already exists.") | ||
genConfigCmd.Flags().VarP(&configLocType, "type", "m", fmt.Sprintf("config generation mode. Valid values: %v", pathutil.AllConfigLocationTypes())) | ||
} | ||
|
||
var genConfigCmd = &cobra.Command{ | ||
Use: "gen-config", | ||
Short: "generates a configuration file", | ||
PreRun: func(_ *cobra.Command, _ []string) { | ||
if output == "" { | ||
output = pathutil.ManagerDefaults().Get(configLocType) | ||
log.Infof("no 'output,o' flag is empty, using default path: %s", output) | ||
} | ||
var err error | ||
if output, err = filepath.Abs(output); err != nil { | ||
log.WithError(err).Fatalln("invalid output provided") | ||
} | ||
}, | ||
Run: func(_ *cobra.Command, _ []string) { | ||
var conf manager.Config | ||
switch configLocType { | ||
case pathutil.WorkingDirLoc: | ||
conf = manager.GenerateWorkDirConfig() | ||
case pathutil.HomeLoc: | ||
conf = manager.GenerateHomeConfig() | ||
case pathutil.LocalLoc: | ||
conf = manager.GenerateLocalConfig() | ||
default: | ||
log.Fatalln("invalid config type:", configLocType) | ||
} | ||
pathutil.WriteJSONConfig(conf, output, replace) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.