Skip to content

Commit

Permalink
Update readme (#35)
Browse files Browse the repository at this point in the history
* update gifs

* beautify help

* update readme
  • Loading branch information
thatstoasty authored Sep 19, 2024
1 parent 67d04ca commit b63f675
Show file tree
Hide file tree
Showing 37 changed files with 271 additions and 104 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] - yyyy-mm-dd

## [0.1.3] - 2024-09-19

- Introduce `mog` dependency for help function formatting.

## [0.1.2] - 2024-09-13

- First release with a changelog! Added rattler build and conda publish.
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Prism

![Mojo 24.5](https://img.shields.io/badge/Mojo%F0%9F%94%A5-24.5-purple)

A Budding CLI Library!

Inspired by: `Cobra`!

> [!NOTE]
> This library will often have breaking changes and it should not be used for anything in production.
![Mojo Version](https://img.shields.io/badge/Mojo%F0%9F%94%A5-24.5-orange)
![Build Status](https://github.com/thatstoasty/prism/actions/workflows/build.yml/badge.svg)
![Test Status](https://github.com/thatstoasty/prism/actions/workflows/test.yml/badge.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation

Expand All @@ -19,7 +19,33 @@ Inspired by: `Cobra`!

Here's an example of a basic command and subcommand!

![Basic Example](https://github.com/thatstoasty/prism/blob/main/doc/images/chromeria.png)
```mojo
from memory import Arc
from prism import Command
fn test(command: Arc[Command], args: List[String]) -> None:
print("Pass chromeria as a subcommand!")
fn hello(command: Arc[Command], args: List[String]) -> None:
print("Hello from Chromeria!")
fn main() -> None:
var root_command = Arc(
Command(
name="hello",
description="This is a dummy command!",
run=test,
)
)
var hello_command = Arc(Command(name="chromeria", description="This is a dummy command!", run=hello))
root_command[].add_command(hello_command)
root_command[].execute()
```

![Chromeria](https://github.com/thatstoasty/prism/blob/main/doc/tapes/hello-chromeria.gif)

Expand Down Expand Up @@ -261,14 +287,9 @@ fn init() -> None:

- Flags can have values passed by using the `=` operator. Like `--count=5` OR like `--count 5`.
- This library leans towards Errors as values over raising Exceptions.
- `Optional[Error]` would be much cleaner for Command `erroring_run` functions. For now return `Error()` if there's no `Error` to return.

## TODO

### Repository

- [ ] Add a description

### Documentation

### Features
Expand Down
Binary file removed doc/images/chromeria.png
Binary file not shown.
Binary file removed doc/images/nested.png
Binary file not shown.
Binary file modified doc/tapes/aliases.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions doc/tapes/aliases.tape
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Output demos/tapes/aliases.gif
Output doc/tapes/aliases.gif

Set Shell "zsh"
Set FontSize 20
Set Width 1200
Set Height 400
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10

Type "mojo build examples/aliases/root.mojo -o aliases" Sleep 500ms Enter
Type "mojo build examples/aliases.mojo -o aliases" Sleep 500ms Enter
Sleep 2s
Type "./aliases" Sleep 500ms Enter
Sleep 2s
Expand Down
Binary file modified doc/tapes/arg_validators.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions doc/tapes/arg_validators.tape
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Output demos/tapes/arg_validators.gif
Output doc/tapes/arg_validators.gif

Set Shell "zsh"
Set FontSize 20
Set Width 1200
Set Height 600
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10


Type "mojo build examples/arg_validators/root.mojo -o validators" Sleep 500ms Enter
Type "mojo build examples/arg_validators.mojo -o validators" Sleep 500ms Enter
Sleep 2s
Type "./validators Hello from Mojo!" Sleep 500ms Enter
Sleep 2s
Expand Down
Binary file added doc/tapes/chromeria.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions doc/tapes/hello-chromeria.tape → doc/tapes/chromeria.tape
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
Output demos/tapes/hello-chromeria.gif
Output doc/tapes/chromeria.gif

Set Shell "zsh"
Set FontSize 23
Set Width 1200
Set Height 300
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10

Type "mojo build examples/hello_chromeria/root.mojo -o hello" Sleep 500ms Enter

Type "mojo build examples/chromeria.mojo -o hello" Sleep 500ms Enter
Sleep 1500ms
Type "./hello" Sleep 500ms Enter
Sleep 1500ms
Expand Down
Binary file modified doc/tapes/flag_groups-2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions doc/tapes/flag_groups-2.tape
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Output demos/tapes/flag_groups-2.gif
Output doc/tapes/flag_groups-2.gif

Set Shell "zsh"
Set FontSize 20
Set Width 1200
Set Height 600
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10


Type "mojo build examples/flag_groups/child.mojo -o group" Sleep 500ms Enter
Type "mojo build examples/fg_child.mojo -o group" Sleep 500ms Enter
Sleep 4s
Type "./group tool --required -a --host=www.example.com --port 8080" Sleep 500ms Enter
Sleep 2s
Expand Down
Binary file modified doc/tapes/flag_groups.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions doc/tapes/flag_groups.tape
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Output demos/tapes/flag_groups.gif
Output doc/tapes/flag_groups.gif

Set Shell "zsh"
Set FontSize 20
Set Width 1200
Set Height 600
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10


Type "mojo build examples/flag_groups/parent.mojo -o group" Sleep 500ms Enter
Type "mojo build examples/fg_parent.mojo -o group" Sleep 500ms Enter
Sleep 3s
Type "./group --required --host=www.example.com --port 8080" Sleep 500ms Enter
Sleep 2s
Expand Down
Binary file removed doc/tapes/hello-chromeria.gif
Binary file not shown.
Binary file modified doc/tapes/help.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions doc/tapes/help.tape
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Output demos/tapes/help.gif
Output doc/tapes/help.gif

Set Shell "zsh"
Set FontSize 20
Set Width 1200
Set Height 600
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10


Type "mojo build examples/flag_groups/child.mojo -o group" Sleep 500ms Enter
Type "mojo build examples/fg_child.mojo -o group" Sleep 500ms Enter
Sleep 3s
Type "./group --help" Sleep 500ms Enter
Sleep 5s
5 changes: 4 additions & 1 deletion doc/tapes/logging.tape
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Output demos/tapes/logging.gif
Output doc/tapes/logging.gif

Set Shell "zsh"
Set FontSize 20
Set Width 1200
Set Height 400
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10

Type "mojo build examples/logging/root.mojo -o logger" Sleep 500ms Enter
Sleep 4s
Expand Down
2 changes: 1 addition & 1 deletion doc/tapes/nested/nested-1.tape
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Output demos/tapes/nested-1.gif
Output doc/tapes/nested-1.gif

Set Shell "zsh"
Set FontSize 32
Expand Down
2 changes: 1 addition & 1 deletion doc/tapes/nested/nested-2.tape
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Hide Hide the subsequent commands from the output
# Show Show the subsequent commands in the output

Output demos/tapes/nested-2.gif
Output doc/tapes/nested-2.gif

Set Shell "zsh"
Set FontSize 30
Expand Down
2 changes: 1 addition & 1 deletion doc/tapes/nested/nested-3.tape
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Hide Hide the subsequent commands from the output
# Show Show the subsequent commands in the output

Output demos/tapes/nested-3.gif
Output doc/tapes/nested-3.gif

Require echo

Expand Down
2 changes: 1 addition & 1 deletion doc/tapes/nested/nested-4.tape
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Hide Hide the subsequent commands from the output
# Show Show the subsequent commands in the output

Output demos/tapes/nested-4.gif
Output doc/tapes/nested-4.gif

Require echo

Expand Down
7 changes: 5 additions & 2 deletions doc/tapes/persistent.tape
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
Output demos/tapes/persistent.gif
Output doc/tapes/persistent.gif

Set Shell "zsh"
Set FontSize 20
Set Width 1200
Set Height 400
Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10

# Type "mojo build examples/persistent/root.mojo -o pet_facts" Sleep 500ms Enter
# Sleep 1500ms
# Type "./pet_facts get dog -l" Sleep 500ms Enter
Type "mojo run examples/persistent/root.mojo get dog -l" Sleep 500ms Enter
Type "mojo run examples/persistent_flags.mojo get dog -l" Sleep 500ms Enter
Sleep 3s
Sleep 5s
6 changes: 4 additions & 2 deletions doc/tapes/printer.tape
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Output demos/tapes/printer.gif
Output doc/tapes/printer.gif

Set Shell "zsh"
Set FontSize 23
Set Width 1200
Set Height 400

Set WindowBar Colorful
Set Theme "Catppuccin Frappe"
Set BorderRadius 10

Type "mojo build examples/printer/printer.mojo -o printer" Sleep 500ms Enter
Sleep 4s
Expand Down
6 changes: 1 addition & 5 deletions examples/aliases.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn tool_func(command: Arc[Command], args: List[String]) -> None:
print("My tool!")


fn init() -> None:
fn main() -> None:
var root_command = Arc(
Command(
name="my",
Expand All @@ -27,7 +27,3 @@ fn init() -> None:

root_command[].add_command(tool_command)
root_command[].execute()


fn main() -> None:
init()
6 changes: 1 addition & 5 deletions examples/arg_validators.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn hello(command: Arc[Command], args: List[String]) -> None:
print(cmd[].name, "Hello from Chromeria!")


fn init() -> None:
fn main() -> None:
var root_command = Arc(
Command(
name="hello",
Expand Down Expand Up @@ -57,7 +57,3 @@ fn init() -> None:
root_command[].add_command(exact_args_command)
root_command[].add_command(range_args_command)
root_command[].execute()


fn main() -> None:
init()
6 changes: 1 addition & 5 deletions examples/chromeria.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn hello(command: Arc[Command], args: List[String]) -> None:
print("Hello from Chromeria!")


fn init() -> None:
fn main() -> None:
var root_command = Arc(
Command(
name="hello",
Expand All @@ -23,7 +23,3 @@ fn init() -> None:

root_command[].add_command(hello_command)
root_command[].execute()


fn main() -> None:
init()
6 changes: 1 addition & 5 deletions examples/fg_child.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn tool_func(command: Arc[Command], args: List[String]) -> None:
print("My tool!")


fn init() -> None:
fn main() -> None:
var root_command = Arc(
Command(
name="my",
Expand All @@ -35,7 +35,3 @@ fn init() -> None:
tool_command[].mark_flags_mutually_exclusive("host", "uri")

root_command[].execute()


fn main() -> None:
init()
6 changes: 1 addition & 5 deletions examples/fg_parent.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn tool_func(command: Arc[Command], args: List[String]) -> None:
print("My tool!")


fn init() -> None:
fn main() -> None:
var root_command = Arc(
Command(
name="my",
Expand All @@ -27,7 +27,3 @@ fn init() -> None:
root_command[].mark_flag_required("required")

root_command[].execute()


fn main() -> None:
init()
6 changes: 1 addition & 5 deletions examples/hello_world.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn test(command: Arc[Command], args: List[String]) -> None:
return None


fn init() -> None:
fn main() -> None:
var root_command = Arc(
Command(
name="tones",
Expand All @@ -102,7 +102,3 @@ fn init() -> None:
root_command[].add_command(printer_command)

root_command[].execute()


fn main() -> None:
init()
6 changes: 1 addition & 5 deletions examples/nested.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn get_dog_breeds(command: Arc[Command], args: List[String]) -> Error:
return Error()


fn init() -> None:
fn main() -> None:
var root_command = Arc(Command(name="nested", description="Base command.", run=base))

var get_command = Arc(
Expand Down Expand Up @@ -98,7 +98,3 @@ fn init() -> None:
get_command[].add_command(dog_command)
root_command[].add_command(get_command)
root_command[].execute()


fn main() -> None:
init()
Loading

0 comments on commit b63f675

Please sign in to comment.