-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'show' argument to print the /etc/hosts file
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -143,5 +143,4 @@ func Execute() { | |
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
return | ||
} |
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,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()) | ||
} |