-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
241 additions
and
81 deletions.
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
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
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 @@ | ||
gleam 0.30.0-rc4 | ||
gleam 0.30.3 |
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
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 |
---|---|---|
|
@@ -15,7 +15,7 @@ jobs: | |
- uses: erlef/[email protected] | ||
with: | ||
otp-version: "25.2" | ||
gleam-version: "0.30.0-rc3" | ||
gleam-version: "0.30.3" | ||
rebar3-version: "3" | ||
# elixir-version: "1.14.2" | ||
- run: gleam format --check src test | ||
|
This file was deleted.
Oops, something went wrong.
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,24 +1,41 @@ | ||
# hello | ||
|
||
[![Package Version](https://img.shields.io/hexpm/v/hello)](https://hex.pm/packages/hello) | ||
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/hello/) | ||
This is an example project that demonstrates a simple workflow using `glint`. | ||
It contains only one command, the root command. | ||
Feel free to browse `src/hello.gleam` to get a sense of how a small cli application is written. | ||
|
||
A Gleam project | ||
## Usage | ||
|
||
## Quick start | ||
### Running the application | ||
|
||
```sh | ||
gleam run # Run the project | ||
gleam test # Run the tests | ||
gleam shell # Run an Erlang shell | ||
``` | ||
You can run this example from the `examples/hello` directory by calling `gleam run` which prints `Hello, <NAMES>!` | ||
|
||
## Installation | ||
The `hello` application accepts any number of arguments, being the names of people to say hello to. | ||
|
||
If available on Hex this package can be added to your Gleam project: | ||
- No input: `gleam run` -> prints "Hello, Joe!" | ||
- One input: `gleam run Rob` -> prints "Hello, Rob!" | ||
- Two inputs: `gleam run Rob Louis` -> prints "Hello, Rob and Louis!" | ||
- \>2 inputs: `gleam run Rob Louis Hayleigh` -> prints "Hello, Rob, Louis and Hayleigh!" | ||
|
||
```sh | ||
gleam add hello | ||
``` | ||
### Flags | ||
|
||
The root command accepts two flags: | ||
|
||
- `--caps`: capitalizes the output, so if output would be "Hello, Joe!" it prints "HELLO, JOE!" | ||
- `--repeat=N`: repeats the output N times separated , so with N=2 if output would be "Hello, Joe!" it prints "Hello, Joe!\nHello, Joe!" | ||
|
||
## Help Output | ||
|
||
and its documentation can be found at <https://hexdocs.pm/hello>. | ||
Generated help output for the root command is as follows | ||
|
||
```txt | ||
Prints Hello, <NAME>! | ||
USAGE: | ||
hello [ ARGS ] [ --caps=<BOOL> --repeat=<INT> ] | ||
FLAGS: | ||
--caps=<BOOL> Capitalize the provided name | ||
--help Print help information | ||
--repeat=<INT> Repeat the message n-times | ||
``` |
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
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,7 +1,38 @@ | ||
import gleeunit | ||
|
||
// import gleeunit/should | ||
import gleeunit/should | ||
import hello | ||
import gleam/list | ||
|
||
pub fn main() { | ||
gleeunit.main() | ||
} | ||
|
||
type TestCase { | ||
TestCase(input: List(String), caps: Bool, repeat: Int, expected: String) | ||
} | ||
|
||
pub fn hello_test() { | ||
use tc <- list.each([ | ||
TestCase([], False, 1, "Hello, Joe!"), | ||
TestCase(["Rob"], False, 1, "Hello, Rob!"), | ||
TestCase([], True, 1, "HELLO, JOE!"), | ||
TestCase([], True, 2, "HELLO, JOE!\nHELLO, JOE!"), | ||
TestCase(["Rob"], True, 1, "HELLO, ROB!"), | ||
TestCase(["Tony", "Maria"], True, 1, "HELLO, TONY AND MARIA!"), | ||
TestCase( | ||
["Tony", "Maria", "Nadia"], | ||
True, | ||
1, | ||
"HELLO, TONY, MARIA AND NADIA!", | ||
), | ||
TestCase(["Tony", "Maria"], False, 1, "Hello, Tony and Maria!"), | ||
TestCase( | ||
["Tony", "Maria", "Nadia"], | ||
False, | ||
1, | ||
"Hello, Tony, Maria and Nadia!", | ||
), | ||
]) | ||
hello.hello(tc.input, tc.caps, tc.repeat) | ||
|> should.equal(tc.expected) | ||
} |
Oops, something went wrong.