Skip to content

Commit

Permalink
Refactor tentacle into its own file
Browse files Browse the repository at this point in the history
Signed-off-by: Blaine Gardner <[email protected]>
  • Loading branch information
BlaineEXE committed Sep 16, 2018
1 parent 9eddf15 commit ee6c6ed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
23 changes: 0 additions & 23 deletions cmd/octopus/octopus.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
package main

import (
"bytes"
"flag"
"fmt"
"log"
"os"
"strings"
)

// Each of octopus's tentacles is a remote connection to a host executing the command
type tentacle struct {
host string
hostname string
stdout *bytes.Buffer
err error
}

func main() {
identityFile := flag.String("identity-file", "~/.ssh/id_rsa",
"identity file used to authenticate to remote hosts")
Expand Down Expand Up @@ -55,17 +46,3 @@ func main() {

os.Exit(numErrors)
}

func (t *tentacle) print() error {
fmt.Println("-----")
fmt.Println(t.hostname)
fmt.Printf("-----\n\n")
o := strings.TrimRight(t.stdout.String(), "\n")
if o != "" {
fmt.Printf("%s\n\n", o)
}
if t.err != nil {
fmt.Printf("Error: %v", t.err)
}
return t.err
}
28 changes: 28 additions & 0 deletions cmd/octopus/tentacle.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"bytes"
"fmt"
"strings"
)

// Each of octopus's tentacles is a remote connection to a host executing the command
type tentacle struct {
hostname string
stdout *bytes.Buffer
err error
}

func (t *tentacle) print() error {
fmt.Println("-----")
fmt.Println(t.hostname)
fmt.Printf("-----\n\n")
o := strings.TrimRight(t.stdout.String(), "\n")
if o != "" {
fmt.Printf("%s\n\n", o)
}
if t.err != nil {
fmt.Printf("Error: %v\n\n", t.err)
}
return t.err
}

0 comments on commit ee6c6ed

Please sign in to comment.