Skip to content

grapi build server fails #235

@potsbo

Description

@potsbo

WHY

I have a repository that contains more than 20 commands, in which sometimes I want to build only one command to save time.
And it looks like grapi offers a way to do that like grapi build <command name> but this doesn't work

$ grapi build server
  ▸  Building server
can't load package: named files must be .go files: server
failed to build [/Users/potsbo/.go/src/github.com/<repo-slug>/cmd/server/main.go /Users/potsbo/.go/src/github.com/<repo-slug>/cmd/server/run.go]: exit status 1

I did a bit of investigation to find out the cause is https://github.com/izumin5210/grapi/blob/master/pkg/grapicmd/internal/module/script/script.go#L67

Since grapi passes the args I give as an arg to the go build command, the go command receives an unexpected arg.

WHAT

I would like to fix this problem by doing below

  • not to take args in Build func
  • not to add the args into go build args

But before doing that I would like to know your intention of this code.
Maybe you wanted to let users to pass build args to go? But this doesn't work because cobra doesn't let us passing args other than specified ones, which means this cannot be done in the current architecture.

$ grapi build server -a
unknown shorthand flag: 'a' in -a

Any suggestion? @izumin5210

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions