Skip to content

Commit

Permalink
show command execution time in sec
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Jan 22, 2018
1 parent c5502de commit e356636
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions commands/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"runtime"
"sort"
"strconv"
"strings"
"sync"
"text/template"
Expand Down Expand Up @@ -217,11 +218,12 @@ func (t *Templating) Run() error {

// clone repository
if tpl != nil {
start := time.Now()
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
s.Suffix = " Cloning repository..."
s.FinalMSG = "Repository cloned!\n"
s.Start()
err := t.cloneRepo(tpl.Url, project.Path)
s.FinalMSG = "Repository cloned! " + strconv.FormatFloat(time.Since(start).Seconds(), 'f', 2, 64) + " sec \n"
s.Stop()
if err != nil {
return err
Expand All @@ -231,15 +233,16 @@ func (t *Templating) Run() error {
}

// spinner progress
start := time.Now()
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
s.Suffix = " Processing templates..."
s.FinalMSG = "Templates proceed!\n"
s.Start()

// start multiple routines
t.startN(runtime.NumCPU())
// close sync.WaitGroup and spinner when finished
defer func() {
s.FinalMSG = "Templates proceed! " + strconv.FormatFloat(time.Since(start).Seconds(), 'f', 2, 64) + " sec \n"
t.stop()
s.Stop()
}()
Expand Down Expand Up @@ -269,6 +272,7 @@ func (t *Templating) Run() error {
if ok {
return filepath.SkipDir
}
return nil
}

var templateData = struct {
Expand Down

0 comments on commit e356636

Please sign in to comment.