diff --git a/README.md b/README.md index a372155..0384503 100644 --- a/README.md +++ b/README.md @@ -18,54 +18,56 @@ HTTP client library. ## Creating plugin ```go -import ( - "context" +package main - "codeberg.org/woodpecker-plugins/go-plugin" - "github.com/urfave/cli/v2" - "github.com/rs/zerolog/log" +import ( + "context" + + "codeberg.org/woodpecker-plugins/go-plugin" + "github.com/rs/zerolog/log" + "github.com/urfave/cli/v2" ) type Settings struct { - // TODO: Plugin settings - SampleFlag string + // TODO: Plugin settings + SampleFlag string } type Plugin struct { - *plugin.Plugin - Settings *Settings + *plugin.Plugin + Settings *Settings } func (p *Plugin) Flags() []cli.Flag { - return []cli.Flag{ - // TODO: Add flags - &cli.StringFlag{ - Name: "sample.flag", - Usage: "sample flag", - EnvVars: []string{"PLUGIN_SAMPLE_FLAG"}, - Destination: &p.Settings.SampleFlag, - }, - } + return []cli.Flag{ + // TODO: Add flags + &cli.StringFlag{ + Name: "sample.flag", + Usage: "sample flag", + EnvVars: []string{"PLUGIN_SAMPLE_FLAG"}, + Destination: &p.Settings.SampleFlag, + }, + } } func (p *Plugin) Execute(ctx context.Context) error { - // TODO: Implement execution - log.Debug().Msg("executed") - return nil + // TODO: Implement execution + log.Debug().Msg("executed") + return nil } func main() { - p := &Plugin{ - &Settings{} - } - - p.Plugin = plugin.New(Options{ - Name: "sample-plugin", - Description: "Sample plugin", - Flags: p.Flags(), - Execute: p.Execute, - }) + p := &Plugin{ + Settings: &Settings{}, + } - p.Run() + p.Plugin = plugin.New(plugin.Options{ + Name: "sample-plugin", + Description: "Sample plugin", + Flags: p.Flags(), + Execute: p.Execute, + }) + + p.Run() } ```