diff --git a/main.go b/main.go index 0ff6b4a..ab67bcb 100644 --- a/main.go +++ b/main.go @@ -3,25 +3,16 @@ package main import ( "fmt" "os" - "time" "github.com/Marvin9/licensor/steps" ) func main() { + fmt.Print("\033[s") // save cursor position + fmt.Print("\033[?25l") // hide cursor + // find . | grep -i "\(\.go\|\.sh\)$" | wc -l - fmt.Print("Working") - go (func() { - for { - for i := 0; i < 3; i++ { - fmt.Print(".") - time.Sleep(time.Millisecond * 500) - } - for i := 0; i < 3; i++ { - fmt.Print("\b \b") - } - } - })() + var model steps.CommandModel model.MakeModel(os.Args) model.Validate() @@ -33,6 +24,10 @@ func main() { } model.Start() - fmt.Print("\r \r") + + // https://www.lihaoyi.com/post/BuildyourownCommandLinewithANSIescapecodes.html#completeness + fmt.Print("\u001b[2K") + fmt.Print("\u001b[0G") fmt.Println("✔️") + fmt.Print("\033[?25h") } diff --git a/steps/iterate_project.go b/steps/iterate_project.go index ee446d8..3c430a2 100644 --- a/steps/iterate_project.go +++ b/steps/iterate_project.go @@ -92,6 +92,13 @@ func (m *CommandModel) iterateDirectory(path string) { continue } + fmt.Print("\u001b[2K") // clear entire line + fmt.Print("\033[u") // restore cursor position (position where porgram started) + fmt.Print("\u001b[2K") // clear entire line [to eliminate overflow issues] + fmt.Print("\u001b[0G") // place cursor to 0th position + fmt.Print(fullpath) + fmt.Print("\u001b[0G") + fileToInjectLicense, err := os.OpenFile(fullpath, os.O_WRONLY, os.ModePerm) if err != nil { utils.LogError(err)