Skip to content

Commit

Permalink
Write full line with -counters option
Browse files Browse the repository at this point in the history
  • Loading branch information
dex4er committed Aug 9, 2023
1 parent 117b0d7 commit e5887e3
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 32 deletions.
8 changes: 8 additions & 0 deletions assets/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.PHONY: all
all: terraform.gif terraform-small.gif tf.gif tf-small.gif

%.gif: %.yml
terminalizer render $< -o $@

%-small.gif: %.gif
convert -verbose $< -resize 30% $@
2 changes: 1 addition & 1 deletion assets/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ config:
# Records, feel free to edit them
records:
- delay: 1
content: "\e[0m"
content: "\r\e[0m"
- delay: 1
content: "$ "
- delay: 100
Expand Down
Binary file modified assets/tf-small.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/tf.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 23 additions & 23 deletions assets/tf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ config:
# Records, feel free to edit them
records:
- delay: 1
content: "\e[0m"
content: "\r\e[0m"
- delay: 1
content: "$ "
- delay: 100
Expand Down Expand Up @@ -153,45 +153,45 @@ records:
- delay: 1
content: "\e[?2004l\r"
- delay: 200
content: "\e[34m^1\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"1\"]: Refreshing state...\r"
content: "\e[34m^1\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"1\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^2\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"4\"]: Refreshing state...\r"
content: "\e[0m\e[34m^2\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"4\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^3\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"5\"]: Refreshing state...\r"
content: "\e[0m\e[34m^3\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"5\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^4\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"3\"]: Refreshing state...\r"
content: "\e[0m\e[34m^4\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"3\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^5\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"6\"]: Refreshing state...\r"
content: "\e[0m\e[34m^5\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"6\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^6\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"9\"]: Refreshing state...\r"
content: "\e[0m\e[34m^6\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"9\"]: Refreshing state... [id=2023-08-06]\r"
- delay: 200
content: "\e[0m\e[34m^7\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"8\"]: Refreshing state...\r"
content: "\e[0m\e[34m^7\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"8\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^8\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"7\"]: Refreshing state...\r"
content: "\e[0m\e[34m^8\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"7\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^9\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"2\"]: Refreshing state...\r"
content: "\e[0m\e[34m^9\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"2\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^10\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"0\"]: Refreshing state...\r"
content: "\e[0m\e[34m^10\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mtime_sleep.this[\"0\"]: Refreshing state... [id=2023-08-06\r"
- delay: 200
content: "\e[0m\e[34m^11\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"1\"]: Refreshing state...\r"
content: "\e[0m\e[34m^11\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"1\"]: Refreshing state... [id=ab8366d720\r"
- delay: 200
content: "\e[0m\e[34m^12\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"0\"]: Refreshing state...\r"
content: "\e[0m\e[34m^12\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"0\"]: Refreshing state... [id=4cf95cb065\r"
- delay: 200
content: "\e[0m\e[34m^13\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"4\"]: Refreshing state...\r"
content: "\e[0m\e[34m^13\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"4\"]: Refreshing state... [id=1fb5a271e3\r"
- delay: 200
content: "\e[0m\e[34m^14\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"2\"]: Refreshing state...\r"
content: "\e[0m\e[34m^14\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"2\"]: Refreshing state... [id=0db0e5fa1e\r"
- delay: 200
content: "\e[0m\e[34m^15\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"7\"]: Refreshing state...\r"
content: "\e[0m\e[34m^15\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"7\"]: Refreshing state... [id=dc80681ca7\r"
- delay: 200
content: "\e[0m\e[34m^16\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"9\"]: Refreshing state...\r"
content: "\e[0m\e[34m^16\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"9\"]: Refreshing state... [id=0b3fcfc3c4\r"
- delay: 200
content: "\e[0m\e[34m^17\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"3\"]: Refreshing state...\r"
content: "\e[0m\e[34m^17\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"3\"]: Refreshing state... [id=ffbb3db597\r"
- delay: 200
content: "\e[0m\e[34m^18\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"5\"]: Refreshing state...\r"
content: "\e[0m\e[34m^18\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"5\"]: Refreshing state... [id=b909326d15\r"
- delay: 200
content: "\e[0m\e[34m^19\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"8\"]: Refreshing state...\r"
content: "\e[0m\e[34m^19\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"8\"]: Refreshing state... [id=18f2cbee97\r"
- delay: 200
content: "\e[0m\e[34m^20\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"6\"]: Refreshing state...\r"
content: "\e[0m\e[34m^20\e[0m \e[36m=0/0\e[0m \e[32m+0/0\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"6\"]: Refreshing state... [id=4a45c68a18\r"
- delay: 200
content: "\e[0m"
- delay: 1000
Expand Down Expand Up @@ -237,9 +237,9 @@ records:
- delay: 1000
content: "\e[0m\e[34m^20\e[0m \e[36m=0/0\e[0m \e[32m+0/2\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"8\"]: Creating...\r"
- delay: 1000
content: "\e[0m\e[34m^20\e[0m \e[36m=0/0\e[0m \e[32m+1/2\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"8\"]: Creation complete after\r\e[0m"
content: "\e[0m\e[34m^20\e[0m \e[36m=0/0\e[0m \e[32m+1/2\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"8\"]: Creation complete after 0s [id=18\r\e[0m"
- delay: 1000
content: "\e[34m^20\e[0m \e[36m=0/0\e[0m \e[32m+2/2\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"9\"]: Creation complete after\r\e[0m"
content: "\e[34m^20\e[0m \e[36m=0/0\e[0m \e[32m+2/2\e[0m \e[33m~0/0\e[0m \e[31m-0/0\e[0m \e[0m\e[1mlocal_file.this[\"9\"]: Creation complete after 0s [id=0b\r\e[0m"
- delay: 1000
content: "\e[0m\e[1m\e[32mApply complete! Resources: 2 added, 0 changed, 0 destroyed. \r\n"
- delay: 1
Expand Down
28 changes: 20 additions & 8 deletions run/terraform_with_progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ func terraformWithProgress(command string, args []string) error {
patternIgnoreCompactFormat := `^\s\s[\s+~-]` +
`|\(config refers to values not yet known\)`

patternRefreshing := `(?:.\[0m.\[1m)?(.*?): (.)(?:efreshing(?: state)?)\.\.\.`
patternStartOperation := `(?:.\[0m.\[1m)?(.*?): (.)(?:eading|reating|estroying|odifying)\.\.\.`
patternStillOperation := `(?:.\[0m.\[1m)?(.*?): Still (.).*ing\.\.\.`
patternStopOperation := `(?:.\[0m.\[1m)?(.*?): (.)(?:ead|reation|estruction|odifications) complete after`
patternRefreshing := `(?:.\[0m.\[1m)?(.*?): (.)(?:efreshing(?: state)?)\.\.\..*?(?:\r?\n|$)`
patternStartOperation := `(?:.\[0m.\[1m)?(.*?): (.)(?:eading|reating|estroying|odifying)\.\.\..*?(?:\r?\n|$)`
patternStillOperation := `(?:.\[0m.\[1m)?(.*?): Still (.).*ing\.\.\..*?(?:\r?\n|$)`
patternStopOperation := `(?:.\[0m.\[1m)?(.*?): (.)(?:ead|reation|estruction|odifications) complete after.*?(?:\r?\n|$)`

patternIgnoreOutputs := `^(Changes to )?Outputs:(\n|$)`

Expand Down Expand Up @@ -246,22 +246,34 @@ func terraformWithProgress(command string, args []string) error {
// verbatim progress format is not processed or ignored
if progressFormat != "verbatim" {
if m := reRefreshing.FindStringSubmatch(line); m != nil {
progress.Refresh(progressFormat, m[0], m[1], m[2])
line := m[0]
line = strings.TrimSuffix(line, "\n")
line = strings.TrimSuffix(line, "\r")
progress.Refresh(progressFormat, line, m[1], m[2])
goto NEXT
}

if m := reStartOperation.FindStringSubmatch(line); m != nil {
progress.Start(progressFormat, m[0], m[1], m[2])
line := m[0]
line = strings.TrimSuffix(line, "\n")
line = strings.TrimSuffix(line, "\r")
progress.Start(progressFormat, line, m[1], m[2])
goto NEXT
}

if m := reStillOperation.FindStringSubmatch(line); m != nil {
progress.Still(progressFormat, m[0], m[1], m[2])
line := m[0]
line = strings.TrimSuffix(line, "\n")
line = strings.TrimSuffix(line, "\r")
progress.Still(progressFormat, line, m[1], m[2])
goto NEXT
}

if m := reStopOperation.FindStringSubmatch(line); m != nil {
progress.Stop(progressFormat, m[0], m[1], m[2])
line := m[0]
line = strings.TrimSuffix(line, "\n")
line = strings.TrimSuffix(line, "\r")
progress.Stop(progressFormat, line, m[1], m[2])
goto NEXT
}
}
Expand Down

0 comments on commit e5887e3

Please sign in to comment.