Thanks to visit codestin.com
Credit goes to github.com

Skip to content

👻💻 Spectre.Console with F# style.

License

galassie/fs-spectre

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FsSpectre

Build status

Spectre.Console with F# style.

FsSpectre is a small library that extends Spectre.Console and allow to write beautiful console applications in a declarative and more F#-friendly way. It leverages Computation Expressions to create the widgets in a declarative style.

Add package

If you want to add this package to your project, execute the following command:

dotnet add package FsSpectre

Build on your machine

If you want to build this library on your machine, execute the following commands:

git clone [email protected]:galassie/fs-spectre.git
cd fs-spectre
dotnet build

Examples

Table

With C# + Spectre.Console:

var table = new Table();
table.AddColumn("Foo");
table.AddColumn(new TableColumn("Bar").Centered());
table.AddRow("Baz", "[green]Qux[/]");
table.AddRow(new Markup("[blue]Corgi[/]"), new Panel("Waldo"));
AnsiConsole.Write(table);

With F# + FsSpectre:

table {
    column_text ""
    column (tableColumn { header "Feature"; centerd })
    row_text [| "Baz"; "[green]Qux[/]" |]
    row [| markup { text "[blue]Corgi[/]" }; panel { content "Waldo" } |]
} |> AnsiConsole.Write

Bar Chart

With C# + Spectre.Console:

AnsiConsole.Write(new BarChart()
    .Width(60)
    .Label("[green bold underline]Number of fruits[/]")
    .CenterLabel()
    .AddItem("Apple", 12, Color.Yellow)
    .AddItem("Orange", 54, Color.Green)
    .AddItem("Banana", 33, Color.Red));

With F# + FsSpectre:

barChart {
    width 60
    label "[green bold underline]Number of fruits[/]"
    center_label
    item "Apple" 12 Color.Yellow
    item "Oranges" 54 Color.Green
    item "Bananas" 33 Color.Red
} |> AnsiConsole.Write

Showcase

To see an example, execute the Showcase.fsx with the following command (you need to build the library first):

dotnet fsi Showcase.fsx

Showcase

Alternatives

If you don't like this style of using Spectre.Console with Computation Expressions, check out these amazing projects:

Contributing

Code contributions are more than welcome! 😻

Please commit any pull requests against the main branch.
If you find any issue, please report it!

License

This project is licensed under The MIT License (MIT).

Author: Enrico Galassi

About

👻💻 Spectre.Console with F# style.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages