Skip to content

Commit

Permalink
Add 'show' argument to print the /etc/hosts file
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyblue committed Dec 2, 2019
1 parent fd1228d commit dc65154
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 0 additions & 1 deletion util/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,4 @@ func Execute() {
fmt.Println(err)
os.Exit(1)
}
return
}
27 changes: 27 additions & 0 deletions util/cmd/show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(showCmd)
}

var showCmd = &cobra.Command{
Use: "show",
Short: "Show hostnames in /etc/hosts",
Long: `Show the content of the /etc/hosts file `,
Args: func(cmd *cobra.Command, args []string) error {
return nil
},
Run: func(cmd *cobra.Command, args []string) {
ShowHosts()
},
}

func ShowHosts() {
fmt.Print(etcHosts.RenderHostsFile())
}

0 comments on commit dc65154

Please sign in to comment.