-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add tapes and .go examples (#5)
* feat: add tapes and .go examples * move to directories * add binaries to gitignore
- Loading branch information
1 parent
fcc8d9c
commit 64474a3
Showing
20 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
*.txt | ||
*.txt | ||
*.gif | ||
|
||
examples/batch2/batch2 | ||
examples/chocolate-chips/chocolate-chips | ||
examples/cookie/cookie | ||
examples/error/error | ||
examples/format/format | ||
examples/log/log | ||
examples/new/new | ||
examples/options/options | ||
examples/oven/oven | ||
examples/temperature/temperature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output batch2.gif | ||
|
||
Set Height 300 | ||
Set Width 1100 | ||
|
||
Type "./batch2" Sleep 500ms Enter | ||
|
||
Sleep 4s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/charmbracelet/log" | ||
) | ||
|
||
func main() { | ||
logger := log.New(log.WithTimestamp(), log.WithTimeFormat(time.Kitchen), | ||
log.WithCaller(), log.WithPrefix("Baking 🍪 ")) | ||
|
||
logger.SetReportTimestamp(false) | ||
logger.SetReportCaller(false) | ||
logger.SetLevel(log.DebugLevel) | ||
logger.Debug("Preparing batch 2...") // DEBUG baking 🍪: Preparing batch 2...} | ||
|
||
batch2 := logger.With("batch", 2, "chocolateChips", true) | ||
batch2.Debug("Adding chocolate chips") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import "github.com/charmbracelet/log" | ||
|
||
func main() { | ||
log.Debug("Cookie 🍪") | ||
log.Info("Hello World!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output cookie.gif | ||
|
||
Set Height 250 | ||
Set Width 700 | ||
|
||
Type "./cookie" Sleep 500ms Enter | ||
|
||
Sleep 3s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/charmbracelet/log" | ||
) | ||
|
||
func main() { | ||
err := fmt.Errorf("too much sugar") | ||
log.Error("failed to bake cookies", "err", err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output error.gif | ||
|
||
Set Height 250 | ||
Set Width 1100 | ||
|
||
Type "./error" Sleep 500ms Enter | ||
|
||
Sleep 3s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/charmbracelet/log" | ||
) | ||
|
||
func main() { | ||
for item := 1; item <= 100; item++ { | ||
log.Info(fmt.Sprintf("Baking %d / 100 ...", item)) | ||
time.Sleep(100 * time.Millisecond) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output format.gif | ||
|
||
Set Height 400 | ||
Set Width 800 | ||
|
||
Type "./format" Sleep 500ms Enter | ||
|
||
Sleep 6s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "log" | ||
|
||
func main() { | ||
log.Print("Baking 101") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output log.gif | ||
|
||
Set Height 250 | ||
Set Width 800 | ||
|
||
Type "./log" Sleep 500ms Enter | ||
|
||
Sleep 3s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package main | ||
|
||
import "github.com/charmbracelet/log" | ||
|
||
func main() { | ||
logger := log.New() | ||
logger.Warn("chewy!", "butter", true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output new.gif | ||
|
||
Set Height 250 | ||
Set Width 500 | ||
|
||
Type "./new" Sleep 500ms Enter | ||
|
||
Sleep 3s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/charmbracelet/log" | ||
) | ||
|
||
func main() { | ||
logger := log.New(log.WithTimestamp(), log.WithTimeFormat(time.Kitchen), | ||
log.WithCaller(), log.WithPrefix("baking 🍪")) | ||
logger.SetReportTimestamp(false) | ||
logger.SetReportCaller(false) | ||
logger.SetLevel(log.DebugLevel) | ||
logger.Debug("Preparing batch 2...") // DEBUG baking 🍪: Preparing batch 2...} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/charmbracelet/log" | ||
) | ||
|
||
func main() { | ||
logger := log.New(log.WithTimestamp(), log.WithTimeFormat(time.Kitchen), | ||
log.WithCaller(), log.WithPrefix("Baking 🍪 ")) | ||
logger.Info("Starting oven!", "degree", 375) | ||
time.Sleep(3 * time.Second) | ||
logger.Info("Finished baking") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output options.gif | ||
|
||
Set Height 300 | ||
Set Width 1200 | ||
|
||
Type "./options" Sleep 500ms Enter | ||
|
||
Sleep 6s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
import "github.com/charmbracelet/log" | ||
|
||
func startOven(degree int) { | ||
log.Helper() | ||
log.Info("Starting oven", "degree", degree) | ||
} | ||
|
||
func main() { | ||
log.SetReportCaller(true) | ||
startOven(400) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output oven.gif | ||
|
||
Set Height 250 | ||
Set Width 1200 | ||
|
||
Type "./oven" Sleep 500ms Enter | ||
|
||
Sleep 3s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/charmbracelet/log" | ||
) | ||
|
||
func main() { | ||
for temp := 375; temp <= 400; temp++ { | ||
log.Info("Increasing temperature", "degree", fmt.Sprintf("%d°F", temp)) | ||
time.Sleep(100 * time.Millisecond) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Output temperature.gif | ||
|
||
Set Height 400 | ||
Set Width 1100 | ||
|
||
Type "./temperature" Sleep 500ms Enter | ||
|
||
Sleep 6s |