Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'show' argument to print the /etc/hosts file #5

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
}