diff --git a/cmd/pretty.go b/cmd/pretty.go deleted file mode 100644 index e46d279..0000000 --- a/cmd/pretty.go +++ /dev/null @@ -1,44 +0,0 @@ -package cmd - -import ( - "bufio" - "fmt" - "log" - "os" - "strings" - - "github.com/spf13/cobra" -) - -func init() { - RootCmd.AddCommand(prettyCmd) -} - -var prettyCmd = &cobra.Command { - Use: "pretty", - Run: func(cmd *cobra.Command, args []string) { - if (len(args) <= 0) { - log.Fatal("no arguments provided") - } - var filename = args[0] - f, err := os.Open(filename) - if err != nil { - log.Fatal(err) - } - - defer f.Close() - - scanner := bufio.NewScanner(f) - - for scanner.Scan() { - line := scanner.Text() - formattedLine := strings.Replace(line, "\\n", "\n", -1) - formattedLine = strings.Replace(formattedLine, "\\t", "\t", -1) - fmt.Fprintf(cmd.OutOrStdout(), formattedLine) - } - - if err := scanner.Err(); err != nil { - log.Fatal(err) - } - }, -} diff --git a/test/pretty_test.go b/test/pretty_test.go deleted file mode 100644 index e89c7bf..0000000 --- a/test/pretty_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package test - -import ( - "bytes" - "testing" - - "github.com/Marcusk19/dotctl/cmd" - "github.com/stretchr/testify/assert" -) - -func TestPrettyCommand(t *testing.T) { - dotctl := cmd.RootCmd - actual := new(bytes.Buffer) - dotctl.SetOut(actual) - dotctl.SetErr(actual) - dotctl.SetArgs([]string{"pretty", "fixtures/test_pretty.txt"}) - dotctl.Execute() - - expected := "The end of this sentence should start a newline. \nThe next sentence should be indented below this one.\n\tHello this is the end of the text" - assert.Equal(t, expected, actual.String(), "actual value differs from expected") -} -