Skip to content

Commit

Permalink
Merge branch 'plugin_no_arguments' of https://github.com/dcarley/cf-cli
Browse files Browse the repository at this point in the history
… into dcarley-plugin_no_arguments

[#140387693]
  • Loading branch information
mmb committed Feb 22, 2017
2 parents 725cfd8 + e95e471 commit fc93d1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugin/plugin_shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import (
* SendMetadata - used to fetch the plugin metadata
**/
func Start(cmd Plugin) {
cliConnection := NewCliConnection(os.Args[1])
if len(os.Args) < 2 {
fmt.Printf("This cf CLI plugin is not intended to be run on its own\n\n")
os.Exit(1)
}

cliConnection := NewCliConnection(os.Args[1])
cliConnection.pingCLI()
if isMetadataRequest(os.Args) {
cliConnection.sendPluginMetadataToCliServer(cmd.GetMetadata())
Expand Down
8 changes: 8 additions & 0 deletions plugin/plugin_shim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ var _ = Describe("Command", func() {
)

Describe(".Start", func() {
It("Exits with status 1 and error message if no arguments are passed", func() {
args := []string{}
session, err := Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter)
Expect(err).ToNot(HaveOccurred())
Eventually(session, 2).Should(Exit(1))
Expect(session).To(gbytes.Say("This cf CLI plugin is not intended to be run on its own"))
})

It("Exits with status 1 if it cannot ping the host port passed as an argument", func() {
args := []string{"0", "0"}
session, err := Start(exec.Command(validPluginPath, args...), GinkgoWriter, GinkgoWriter)
Expand Down

0 comments on commit fc93d1a

Please sign in to comment.