-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95800d0
commit a74d429
Showing
6 changed files
with
217 additions
and
65 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/nexentra/midgard/cmd/app" | ||
"github.com/nexentra/midgard/pkg/clients/logger" | ||
"github.com/nexentra/midgard/pkg/config" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// appCmd represents the start command | ||
var appCmd = &cobra.Command{ | ||
Use: "app <option>", | ||
Short: "App service", | ||
Long: `Start app service. | ||
When running this command without options, it will start open desktop app. | ||
If you wish to add any options instead, you can choose from the | ||
available options.`, | ||
|
||
Run: execAppCmd, | ||
} | ||
|
||
func init() { | ||
// This is auto executed upon start | ||
// Initialization processes can go here ... | ||
|
||
// Register sub commands | ||
// appCmd.AddCommand(start.PublicApiCmd) | ||
// appCmd.AddCommand(start.ProtectedApiCmd) | ||
// appCmd.AddCommand(start.HiddenApiCmd) | ||
// appCmd.AddCommand(start.WatcherCmd) | ||
|
||
// Set global flags | ||
appCmd.PersistentFlags().BoolVar(&config.StartWatcherFlag, "watcher", false, "Start watcher daemon in background") | ||
appCmd.PersistentFlags().StringVarP(&config.HostFlag, "host", "H", "", "Service host") | ||
appCmd.PersistentFlags().StringVar(&config.ProtectedPortFlag, "protected-api-port", "", "Protected API Service port") | ||
appCmd.PersistentFlags().StringVar(&config.PublicPortFlag, "public-api-port", "", "Public API Service port") | ||
appCmd.PersistentFlags().StringVar(&config.HiddenPortFlag, "hidden-api-port", "", "Hidden API Service port") | ||
|
||
// Register persistent function for all sub commands | ||
appCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) { | ||
rootCmd.PersistentPreRun(cmd, args) | ||
execAppPersistentPreRun() | ||
} | ||
|
||
// Register start command | ||
rootCmd.AddCommand(appCmd) | ||
} | ||
|
||
func execAppPersistentPreRun() { | ||
logger.Debug("Executing start persistent pre run ...") | ||
|
||
// You can initialize other features here ... | ||
// this will run before any command, make sure to put only global initializations here | ||
// to avoid running into nil pointers or undefined variables | ||
// ... | ||
} | ||
|
||
func execAppCmd(cmd *cobra.Command, args []string) { | ||
app.WailsStart.Run(cmd, args) | ||
} |
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,46 @@ | ||
package app | ||
|
||
import ( | ||
client "github.com/nexentra/midgard/client" | ||
wailsapp "github.com/nexentra/midgard/pkg/app/init" | ||
"github.com/spf13/cobra" | ||
"github.com/wailsapp/wails/v2" | ||
"github.com/wailsapp/wails/v2/pkg/options" | ||
"github.com/wailsapp/wails/v2/pkg/options/assetserver" | ||
) | ||
|
||
// WailsStart represents the protectedApi command | ||
var WailsStart = &cobra.Command{ | ||
Use: "wails", | ||
Short: "Start wails service", | ||
Long: `Start wails app servive.`, | ||
Run: execWailsStart, | ||
} | ||
|
||
func init() { | ||
// This is auto executed upon start | ||
// Initialization processes can go here ... | ||
} | ||
|
||
func execWailsStart(cmd *cobra.Command, args []string) { | ||
app := wailsapp.NewApp() | ||
|
||
// Create application with options | ||
err := wails.Run(&options.App{ | ||
Title: "midgard", | ||
Width: 1024, | ||
Height: 768, | ||
AssetServer: &assetserver.Options{ | ||
Assets: client.BuildFs, | ||
}, | ||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1}, | ||
OnStartup: app.Startup, | ||
Bind: []interface{}{ | ||
app, | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
println("Error:", err.Error()) | ||
} | ||
} |
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,13 @@ | ||
{ | ||
"$schema": "https://wails.io/schemas/config.v2.json", | ||
"name": "midgard", | ||
"outputfilename": "midgard", | ||
"frontend:install": "npm install", | ||
"frontend:build": "npm run build", | ||
"frontend:dev:watcher": "npm run dev", | ||
"frontend:dev:serverUrl": "auto", | ||
"author": { | ||
"name": "KnockOutEZ", | ||
"email": "ktowhid20@gmail.com" | ||
} | ||
} |
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.