-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rony] add helper method to generate stub
- Loading branch information
Showing
6 changed files
with
51 additions
and
1 deletion.
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
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 was deleted.
Oops, something went wrong.
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,26 @@ | ||
package rony | ||
|
||
import "github.com/clubpay/ronykit/stub/stubgen" | ||
|
||
// GenerateStub generates a stub file for the given service description. | ||
// The generated file will be placed in the `outputDir/folderName` directory. | ||
// The package name of the generated file will be `pkgName`. | ||
// The struct holding the stub functions will be named `name`. | ||
func GenerateStub[S State[A], A Action]( | ||
name, folderName, outputDir, pkgName string, | ||
genFunc stubgen.GenFunc, ext string, | ||
opt ...SetupOption[S, A], | ||
) error { | ||
ctx := SetupContext[S, A]{} | ||
for _, o := range opt { | ||
o(&ctx) | ||
} | ||
|
||
return stubgen.New( | ||
stubgen.WithStubName(name), | ||
stubgen.WithFolderName(folderName), | ||
stubgen.WithOutputDir(outputDir), | ||
stubgen.WithPkgName(pkgName), | ||
stubgen.WithGenFunc(genFunc, ext), | ||
).Generate(ctx.cfg.allServiceDesc()...) | ||
} |
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,12 @@ | ||
package main | ||
|
||
import ( | ||
"{{.ModulePath}}/service" | ||
) | ||
|
||
func main() { | ||
err := service.GenerateStub() | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
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