File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -45,27 +45,30 @@ func Run() {
4545}
4646
4747func (t * toc ) logic () {
48+ red := color .New (color .FgRed , color .Bold ).PrintlnFunc ()
49+
4850 resp , err := t .readFile ()
4951 if err != nil {
50- color . Red ( err .Error ())
52+ red ( "ERROR: " + err .Error ())
5153 os .Exit (1 )
5254 }
5355
5456 err = t .parseHTML (resp )
5557 if err != nil {
56- color . Red ( err .Error ())
58+ red ( "ERROR: " + err .Error ())
5759 os .Exit (1 )
5860 }
5961
60- if t .Options .Append == true {
61- if err = t .writeToFile (string (resp )); err != nil {
62- color .Red (err .Error ())
63- os .Exit (1 )
64- }
65- color .Green ("✔ Table of contents generated successfully" )
66- } else {
62+ if t .Options .Append != true {
6763 fmt .Print (t .String ())
64+ return
65+ }
66+
67+ if err = t .writeToFile (string (resp )); err != nil {
68+ red ("ERROR: " + err .Error ())
69+ os .Exit (1 )
6870 }
71+ color .Green ("✔ Table of contents generated successfully" )
6972
7073}
7174
@@ -140,7 +143,7 @@ func (t *toc) add(content string) {
140143
141144func (t * toc ) readFile () ([]byte , error ) {
142145 if _ , err := os .Stat (t .Options .Path ); os .IsNotExist (err ) {
143- return nil , fmt .Errorf (fmt .Sprintf ("path (%s) doesn't exists" , t .Options .Path ))
146+ return nil , fmt .Errorf (fmt .Sprintf ("path '%s' doesn't exists" , t .Options .Path ))
144147 }
145148
146149 file , err := ioutil .ReadFile (t .Options .Path )
You can’t perform that action at this time.
0 commit comments