Skip to content

Commit

Permalink
docs: add demonstrating gif to readme (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
miampf authored Jun 5, 2024
1 parent 94c593c commit 0072e02
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 34 deletions.
Binary file added docs/images/example.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 removed docs/images/screenshot.png
Binary file not shown.
27 changes: 4 additions & 23 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
# example
# Glitzer example

[![Package Version](https://img.shields.io/hexpm/v/example)](https://hex.pm/packages/example)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/example/)
This is a tiny example project for glitzer.

```sh
gleam add example
```
```gleam
import example
pub fn main() {
// TODO: An example of the project in use
}
```

Further documentation can be found at <https://hexdocs.pm/example>.

## Development

```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```
(Please note that the ffi only exists because I use sleeping to simulate hard
work in this example. No ffi is needed to use glitzer)
1 change: 1 addition & 0 deletions example/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ version = "1.0.0"

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
glitzer = ">= 1.0.0 and < 2.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"
6 changes: 6 additions & 0 deletions example/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_community_ansi", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "FE79E08BF97009729259B6357EC058315B6FBB916FAD1C2FF9355115FEB0D3A4" },
{ name = "gleam_community_colour", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "795964217EBEDB3DA656F5EB8F67D7AD22872EB95182042D3E7AFEF32D3FD2FE" },
{ name = "gleam_json", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9063D14D25406326C0255BDA0021541E797D8A7A12573D849462CAFED459F6EB" },
{ name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
{ name = "gleeunit", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "72CDC3D3F719478F26C4E2C5FED3E657AC81EC14A47D2D2DEBB8693CA3220C3B" },
{ name = "glitzer", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_stdlib"], otp_app = "glitzer", source = "hex", outer_checksum = "349489204217589D1E3133AEF8F8BB828409CA53DD82904268777C44D278B612" },
{ name = "thoas", version = "1.2.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "E38697EDFFD6E91BD12CEA41B155115282630075C2A727E7A6B2947F5408B86A" },
]

[requirements]
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
glitzer = { version = ">= 1.0.0 and < 2.0.0"}
22 changes: 11 additions & 11 deletions example/src/example.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ pub fn sleep(ms: Int) -> a

pub fn main() {
let bar =
progress.fancy_thick_bar()
|> progress.with_length(10)
progress.thick_bar()
|> progress.with_length(100)

do_something(bar, 0)
do_something_else()
do_cool_shit_with_2_it()
}

fn do_something(bar, count) {
case count < 10 {
case count < 100 {
True -> {
let bar = progress.tick(bar)
progress.print_bar(bar)
sleep(100)
sleep(30)
do_something(bar, count + 1)
}
False -> Nil
Expand All @@ -32,27 +32,27 @@ fn do_something(bar, count) {
fn do_something_else() {
let bar =
progress.fancy_slim_arrow_bar()
|> progress.with_length(10)
|> progress.with_length(100)

iterator.range(0, 10)
iterator.range(0, 100)
|> progress.each_iterator(bar, fn(bar, i) {
progress.with_left_text(bar, int.to_string(i) <> " ")
|> progress.print_bar
sleep(100)
sleep(30)
})
}

fn do_cool_shit_with_2_it() {
let bar =
progress.default_bar()
|> progress.with_length(10)
let i1 = iterator.range(0, 10)
let i2 = iterator.range(100, 150)
|> progress.with_length(100)
let i1 = iterator.range(0, 100)
let i2 = iterator.range(100, 200)
progress.map2_iterator(i1, i2, bar, fn(bar, e1, e2) {
progress.with_left_text(bar, int.to_string(e1) <> " ")
|> progress.with_right_text(" " <> int.to_string(e2))
|> progress.print_bar
sleep(100)
sleep(50)
})
|> iterator.run
}

0 comments on commit 0072e02

Please sign in to comment.