https://github.com/tynanbe/shellout
🐢 A Gleam library for cross-platform shell operations
https://github.com/tynanbe/shellout
Last synced: about 1 month ago
JSON representation
🐢 A Gleam library for cross-platform shell operations
- Host: GitHub
- URL: https://github.com/tynanbe/shellout
- Owner: tynanbe
- License: apache-2.0
- Created: 2021-01-25T23:18:10.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-15T20:00:13.000Z (about 2 months ago)
- Last Synced: 2025-02-15T21:17:28.788Z (about 2 months ago)
- Language: Gleam
- Homepage:
- Size: 124 KB
- Stars: 55
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - shellout - [📚](https://hexdocs.pm/shellout/) - A Gleam library for cross-platform shell operations (Packages / Command Line)
README
# shellout 🐢
[](https://hex.pm/packages/shellout)
[](https://hexdocs.pm/shellout/)
[](https://github.com/tynanbe/shellout/blob/main/LICENSE)
[](https://github.com/tynanbe/shellout/actions)A Gleam library for cross-platform shell operations.
## Usage
### Example
• In `my_project/src/my_project.gleam`
```gleam
import gleam/dict
import gleam/io
import gleam/result
import shellout.{type Lookups}pub const lookups: Lookups = [
#(
["color", "background"],
[
#("buttercup", ["252", "226", "174"]),
#("mint", ["182", "255", "234"]),
#("pink", ["255", "175", "243"]),
],
),
]pub fn main() {
shellout.arguments()
|> shellout.command(run: "ls", in: ".", opt: [])
|> result.map(with: fn(output) {
io.print(output)
0
})
|> result.map_error(with: fn(detail) {
let #(status, message) = detail
let style =
shellout.display(["bold", "italic"])
|> dict.merge(from: shellout.color(["pink"]))
|> dict.merge(from: shellout.background(["brightblack"]))
message
|> shellout.style(with: style, custom: lookups)
|> io.print_error
status
})
|> result.unwrap_both
|> shellout.exit
}
```### 🐚 You can test the above example with your shell!
• In your terminal
```shell
> cd my_project
> gleam run -- -lah
# ..
> gleam run -- --lah
# ..
> gleam run --target=javascript -- -lah
# ..
> gleam run --target=javascript -- --lah
# ..
```
## Installation
### As a dependency of your Gleam project
• Add `shellout` to `gleam.toml`
```shell
gleam add shellout
```### As a dependency of your Mix project
• Add `shellout` to `mix.exs`
```elixir
defp deps do
[
{:shellout, "~> 1.6"},
]
end
```### As a dependency of your Rebar3 project
• Add `shellout` to `rebar.config`
```erlang
{deps, [
{shellout, "1.6.0"}
]}.
```