~eliasnaur/gio

Mailing list for the Gio project for discussion and patches.

Send your message to ~eliasnaur/gio@lists.sr.ht. No account is required and you can post without being subscribed.

1

use "." as default package

Gregory Pomerantz
Details
Message ID
<42b7246f-09f6-3eb8-8f2a-f5438e56f64e@wow.st>
DKIM signature
pass
Download raw message
If no arguments are specified, can gio default to building the go 
package in the current directory? This would make it more consistent 
with the other tools such as "go build".


diff --git a/cmd/gio/gio.go b/cmd/gio/gio.go
index db23ae5..030358d 100644
--- a/cmd/gio/gio.go
+++ b/cmd/gio/gio.go
@@ -58,7 +58,8 @@ func main() {
  func mainErr() error {
         pkg := flag.Arg(0)
         if pkg == "" {
-               return errors.New("specify a package")
+               pkg = "."
         }
         if *target == "" {
                 return errors.New("please specify -target")
@@ -108,9 +109,9 @@ func mainErr() error {
         if *archNames != "" {
                 bi.archs = strings.Split(*archNames, ",")
         }
-       if appArgs := flag.Args()[1:]; len(appArgs) > 0 {
+       if len(flag.Args()) > 1 {
                 // Pass along arguments to the app.
-               bi.ldflags = fmt.Sprintf("-X 
gioui.org/ui/app.extraArgs=%s", strings.Join(appArgs, "|"))
+               bi.ldflags = fmt.Sprintf("-X 
gioui.org/ui/app.extraArgs=%s", strings.Join(flag.Args()[1:], "|"))
         }
         if err := build(bi); err != nil {
                 return fmt.Errorf("gio: %v", err)
Details
Message ID
<BWXB8OTEVM3C.3PXJT16AEB2I5@testmac>
In-Reply-To
<42b7246f-09f6-3eb8-8f2a-f5438e56f64e@wow.st> (view parent)
DKIM signature
pass
Download raw message
On Wed Sep 11, 2019 at 10:41 AM Gregory Pomerantz wrote:
> If no arguments are specified, can gio default to building the go 
> package in the current directory? This would make it more consistent 
> with the other tools such as "go build".
> 

Sounds reasonable, except that "gio" accepts flags for the app and is
thus more like "go run", and "go run" does not support a default package.
See the discussion at

	https://github.com/golang/go/issues/22726

In particular Chris' comment about flag ambiguity:

	https://github.com/golang/go/issues/22726#issuecomment-347594858

-- elias