File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ $ gofmtmd testdata/testdata.md -r
2020
2121# write result to file instead of stdout
2222$ gofmtmd testdata/testdata.md -w formatted.md
23+
24+ # you can use stdndard input
25+ $ gofmtmd < testdata/testdata.md
26+ $ echo " #hello" | gofmtmd
2327```
2428
2529## Help
Original file line number Diff line number Diff line change 1717
1818var rootCmd = & cobra.Command {
1919 Use : "gofmtmd" ,
20- Version : "0.1.1 " ,
20+ Version : "0.1.2 " ,
2121 Short : "This CLI formats Go Code in Markdown." ,
2222 Args : cobra .MaximumNArgs (1 ),
2323 Run : func (cmd * cobra.Command , args []string ) {
@@ -46,18 +46,19 @@ var rootCmd = &cobra.Command{
4646 if err != nil {
4747 log .Fatalf ("[gofmtmd] failed to writes to %v: %v" , filename , err )
4848 }
49- }
50- if outputfile != "" {
51- err = ioutil .WriteFile (outputfile , out , 0644 )
52- if err != nil {
53- log .Fatalf ("[gofmtmd] failed to writes to %v: %v" , filename , err )
54- }
49+ return
5550 }
5651 }
57- if ! replace && outputfile == "" {
58- writer := os .Stdout
59- fmt .Fprint (writer , string (out ))
52+ if outputfile != "" {
53+ err := ioutil .WriteFile (outputfile , out , 0644 )
54+ if err != nil {
55+ log .Fatalf ("[gofmtmd] failed to writes to %v: %v" , outputfile , err )
56+ }
57+ return
6058 }
59+
60+ writer := os .Stdout
61+ fmt .Fprint (writer , string (out ))
6162 },
6263}
6364
You can’t perform that action at this time.
0 commit comments