Skip to content

Commit

Permalink
Allow -appargs flag to pass flags to binary. (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmjones authored Jul 6, 2022
1 parent 73f5cc3 commit f4b4e4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions v2/cmd/wails/internal/commands/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
command.IntFlag("debounce", "The amount of time to wait to trigger a reload on change", &flags.debounceMS)
command.StringFlag("devserver", "The address of the wails dev server", &flags.devServer)
command.StringFlag("frontenddevserverurl", "The url of the external frontend dev server to use", &flags.frontendDevServerURL)
command.StringFlag("appargs", "arguments to pass to the underlying app (quoted and space searated)", &flags.appargs)
command.StringFlag("appargs", "arguments to pass to the underlying app (quoted and space separated)", &flags.appargs)
command.BoolFlag("save", "Save given flags as defaults", &flags.saveConfig)
command.BoolFlag("race", "Build with Go's race detector", &flags.raceDetector)

Expand Down Expand Up @@ -560,7 +560,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
assetDirURL := joinPath(devServerURL, "/wails/assetdir")
reloadURL := joinPath(devServerURL, "/wails/reload")
for quit == false {
//reload := false
// reload := false
select {
case exitCode := <-exitCodeChannel:
if exitCode == 0 {
Expand Down Expand Up @@ -605,7 +605,7 @@ func doWatcherLoop(buildOptions *build.Options, debugBinaryProcess *process.Proc
if item.Op&fsnotify.Create == fsnotify.Create {
// If this is a folder, add it to our watch list
if fs.DirExists(item.Name) {
//node_modules is BANNED!
// node_modules is BANNED!
if !strings.Contains(item.Name, "node_modules") {
err := watcher.Add(item.Name)
if err != nil {
Expand Down
15 changes: 10 additions & 5 deletions v2/internal/appng/app_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,37 @@ func CreateApp(appoptions *options.App) (*App, error) {
myLogger.SetLogLevel(appoptions.LogLevel)

// Check for CLI Flags
devFlags := flag.NewFlagSet("dev", flag.ContinueOnError)

var assetdirFlag *string
var devServerFlag *string
var frontendDevServerURLFlag *string
var loglevelFlag *string

assetdir := os.Getenv("assetdir")
if assetdir == "" {
assetdirFlag = flag.String("assetdir", "", "Directory to serve assets")
assetdirFlag = devFlags.String("assetdir", "", "Directory to serve assets")
}

devServer := os.Getenv("devserver")
if devServer == "" {
devServerFlag = flag.String("devserver", "", "Address to bind the wails dev server to")
devServerFlag = devFlags.String("devserver", "", "Address to bind the wails dev server to")
}

frontendDevServerURL := os.Getenv("frontenddevserverurl")
if frontendDevServerURL == "" {
frontendDevServerURLFlag = flag.String("frontenddevserverurl", "", "URL of the external frontend dev server")
frontendDevServerURLFlag = devFlags.String("frontenddevserverurl", "", "URL of the external frontend dev server")
}

loglevel := os.Getenv("loglevel")
if loglevel == "" {
loglevelFlag = flag.String("loglevel", "debug", "Loglevel to use - Trace, Debug, Info, Warning, Error")
loglevelFlag = devFlags.String("loglevel", "debug", "Loglevel to use - Trace, Debug, Info, Warning, Error")
}

// If we weren't given the assetdir in the environment variables
if assetdir == "" {
flag.Parse()
// Parse args but ignore errors in case -appargs was used to pass in args for the app.
_ = devFlags.Parse(os.Args[1:])
if assetdirFlag != nil {
assetdir = *assetdirFlag
}
Expand Down

0 comments on commit f4b4e4c

Please sign in to comment.