This repository has been archived by the owner on Jul 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds a plugcmds package and makes writing plugins even simpler (#6)
* adds a plugcmds package and makes writing plugins even simpler * cleaned up the way listen commands are setup * removed accidental hardcoded short name * shuffled the listen command around
- Loading branch information
Showing
15 changed files
with
289 additions
and
112 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,20 @@ | ||
package cmd | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/gobuffalo/buffalo-plugins/plugins" | ||
"github.com/gobuffalo/buffalo-plugins/plugins/plugcmds" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var Available = plugcmds.NewAvailable() | ||
|
||
var pluginsCmd = &cobra.Command{ | ||
Use: "plugins", | ||
Short: "tools for working with buffalo plugins", | ||
} | ||
|
||
// availableCmd represents the available command | ||
var availableCmd = &cobra.Command{ | ||
Use: "available", | ||
Short: "a list of available buffalo plugins", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
plugs := plugins.Commands{ | ||
{Name: generateCmd.Use, BuffaloCommand: "generate", Description: generateCmd.Short, Aliases: generateCmd.Aliases}, | ||
{Name: pluginsCmd.Use, BuffaloCommand: "root", Description: pluginsCmd.Short, Aliases: pluginsCmd.Aliases}, | ||
{Name: "listen", UseCommand: "listen", BuffaloCommand: "events", Description: listenCmd.Short, Aliases: listenCmd.Aliases}, | ||
} | ||
return json.NewEncoder(os.Stdout).Encode(plugs) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(pluginsCmd) | ||
rootCmd.AddCommand(availableCmd) | ||
Available.Add("generate", generateCmd) | ||
Available.Add("root", pluginsCmd) | ||
Available.Listen(Listen) | ||
Available.Mount(rootCmd) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package <%= opts.ShortName %> | ||
|
||
import "github.com/gobuffalo/events" | ||
|
||
func Listen(e events.Event) error { | ||
// do work | ||
return nil | ||
} |
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 |
---|---|---|
@@ -1,25 +1,20 @@ | ||
package cmd | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/gobuffalo/buffalo-plugins/plugins" | ||
"github.com/gobuffalo/buffalo-plugins/plugins/plugcmds" | ||
"github.com/spf13/cobra" | ||
"<%= opts.PluginPkg %>" | ||
) | ||
|
||
// availableCmd represents the available command | ||
var availableCmd = &cobra.Command{ | ||
Use: "available", | ||
Short: "a list of available buffalo plugins", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
plugs := plugins.Commands{ | ||
// {Name: "<%= opts.ShortName %>", UseCommand: "generate", BuffaloCommand: "generate", Description: generateCmd.Short, Aliases: generateCmd.Aliases}, | ||
} | ||
return json.NewEncoder(os.Stdout).Encode(plugs) | ||
}, | ||
var Available = plugcmds.NewAvailable() | ||
|
||
var pluginsCmd = &cobra.Command{ | ||
Use: "plugins", | ||
Short: "tools for working with buffalo plugins", | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(availableCmd) | ||
Available.Add("root", pluginsCmd) | ||
Available.Listen(<%= opts.ShortName %>.Listen) | ||
Available.Mount(rootCmd) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
25 changes: 0 additions & 25 deletions
25
genny/plugin/with/generate/templates/cmd/available.go.plush
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
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
Oops, something went wrong.