Skip to content

Commit

Permalink
release v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Feb 14, 2021
1 parent 28c5d03 commit d6e3407
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func main() {
replaceOption := flag.String("replace", "", "Replace string in line with '-find' option")
splitOption := flag.String("split", "", "Split string within line. (to line , to table, to md-table)")
formatOption := flag.String("format", "line", "Change output format (json, md-table, html-table)")
debugOption := flag.Bool("debug", false, "Show debug message!")

// Custom usage
flag.Usage = func() {
Expand Down Expand Up @@ -76,8 +77,12 @@ func main() {
Color: !*colorOption,
Split: *splitOption,
Format: *formatOption,
Debug: *debugOption,
}
if *debugOption {
printing.DebugMsg("MSG","Running on Debug mode")
printing.DebugMsg("FILES",files)
}

// Running gee app
app.Gee(options)
}
14 changes: 10 additions & 4 deletions pkg/gee/gee.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (

// Gee is running gee
func Gee(options model.Options) {
if options.Debug {
printing.DebugMsg("MSG","Starting gee")
}
sc := bufio.NewScanner(os.Stdin)
mode := os.O_CREATE | os.O_WRONLY
var files = []*os.File{}
Expand All @@ -25,8 +28,8 @@ func Gee(options model.Options) {

for _, filename := range options.Files {
f, err := os.OpenFile(filename, mode, 0644)
if err != nil {

if err != nil && options.Debug {
printing.DebugMsg("ERROR",err)
} else {
files = append(files, f)
}
Expand All @@ -53,8 +56,8 @@ func Gee(options model.Options) {
ClosedFiles(files)
for _, filename := range options.Files {
f, err := os.OpenFile(filename+"_"+strconv.Itoa(stdPointer), mode, 0644)
if err != nil {
printing.ErrPrint(err)
if err != nil && options.Debug {
printing.DebugMsg("ERROR",err)
} else {
files = append(files, f)
}
Expand Down Expand Up @@ -82,4 +85,7 @@ func Gee(options model.Options) {

// Graceful shutdown
ClosedFiles(files)
if options.Debug {
printing.DebugMsg("MSG","Finish gee, graceful shutdown...")
}
}
1 change: 1 addition & 0 deletions pkg/model/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ type Options struct {
Replace string
Find string
Color bool
Debug bool
}
11 changes: 11 additions & 0 deletions pkg/printing/logger.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package printing

import (
"fmt"

"github.com/logrusorgru/aurora"
)

// DebugMsg is msg for debug
func DebugMsg(t string,m interface{}){
fmt.Printf("%s%s%s\n",aurora.BrightYellow("[DEBUG]").String(),aurora.BrightBlue("["+t+"] ").String(),m)
}

// ErrPanic is panic error
func ErrPanic(e error) {

Expand Down
2 changes: 1 addition & 1 deletion pkg/printing/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package printing

// VERSION is version of gee
const VERSION = "v1.0.1"
const VERSION = "v1.0.2"

0 comments on commit d6e3407

Please sign in to comment.