• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 4 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A dotnet tool to list and run examples

dotnet example

A dotnet tool to list and run examples similar to Rust's cargo run --example.

Installing

> dotnet tool install -g dotnet-example

Listing examples

> dotnet example

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Example     โ”‚ Description                                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ CSharp      โ”‚ Writes 'Hello from C#' to the console        โ”‚
โ”‚ FSharp      โ”‚ Writes 'Hello from F#' to the console        โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Type dotnet example --help for help

Running individual examples

> dotnet example csharp
Hello from C#

> dotnet example fsharp
Hello from F#

Running all examples

> dotnet example --all
โ”€โ”€ Example: CSharp โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Hello from C#

โ”€โ”€ Example: FSharp โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Hello from F#

Showing example source code

> dotnet example fsharp --source

โ•ญโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ 1  โ”‚ // Learn more about F# at http://docs.microsoft.com/dotnet/fsharp โ”‚
โ”‚ 2  โ”‚                                                                   โ”‚
โ”‚ 3  โ”‚ open System                                                       โ”‚
โ”‚ 4  โ”‚                                                                   โ”‚
โ”‚ 5  โ”‚ // Define a function to construct a message to print              โ”‚
โ”‚ 6  โ”‚ let from whom =                                                   โ”‚
โ”‚ 7  โ”‚     sprintf "from %s" whom                                        โ”‚
โ”‚ 8  โ”‚                                                                   โ”‚
โ”‚ 9  โ”‚ [<EntryPoint>]                                                    โ”‚
โ”‚ 10 โ”‚ let main argv =                                                   โ”‚
โ”‚ 11 โ”‚     let message = from "F#" // Call the function                  โ”‚
โ”‚ 12 โ”‚     printfn "Hello %s" message                                    โ”‚
โ”‚ 13 โ”‚     0 // return an integer exit code                              โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Conventions

The convention is simple, if there is an examples or samples folder in the directory the tool is executed in, it will fetch all csproj/fsproj files and find the best match to the query.

If examples are located in unconventional folders, add a .examples file with the (relative) paths of the examples folders, one per line. Blank lines or lines starting with # in the .examples file are ignored.

Example settings

To change the name, description, and the order of an example, edit its csproj/fsproj file, and add the following section:

<PropertyGroup>
  <ExampleTitle>Foo</ExampleTitle>
  <ExampleDescription>This is the description of the example.</ExampleDescription>
  <ExampleOrder>5</ExampleOrder>
</PropertyGroup>

If no name is set in the csproj file, the project name will be used. To ignore an example, add the ExampleVisible property in the example's csproj/fsproj file.

<PropertyGroup>
  <ExampleVisible>false</ExampleTitle>
</PropertyGroup>

More Repositories

1

cupboard

A framework for provisioning local environments to a desired state, using the .NET SDK.
C#
760
star
2

ghostly

Ghostly is a GitHub notification client for Windows 10/11
C#
284
star
3

wisp

A low-level library for interacting with PDF files
C#
93
star
4

machine

Contains my install scripts and configurations for Windows and Linux
PowerShell
81
star
5

covenant

A tool to generate SBOM (Software Bill of Material) from source code artifacts.
C#
60
star
6

license-key

A library for generating and verifying license keys.
Rust
54
star
7

fantasma

Fantasma is a minimalistic, opinionated job scheduler library for ASP.NET Core, with a MediatR-like API.
C#
50
star
8

mew-prototype

A research project for building a compiler in C#
C#
45
star
9

autograph

A utility that creates dot graphs from .NET projects
C#
38
star
10

get-the-fork-out

A dotnet tool to delete GitHub forks for a user.
C#
18
star
11

spdx

A .NET library that makes it easy to retrieve information about SPDX licenses.
C#
15
star
12

spectre-kit

A Swift framework that makes it easier to create beautiful console applications.
Swift
15
star
13

dotnet-release-artifacts

C#
12
star
14

rosetta

C#
12
star
15

dotnet-make

A build tool for your build tools.
C#
11
star
16

bender

A tool that generates Bicep files from Aspire manifests.
C#
9
star
17

ntiled

Library for working with Tiled maps (tmx).
C#
8
star
18

spectre.tui

A TUI library for Spectre.Console.
C#
7
star
19

bytestream-rs

Provides a convenient way of reading and writing bytes to a buffer.
Rust
7
star
20

hush

Hush is a Windows application that mutes and unmutes the primary microphone.
C#
7
star
21

bayeux

A .NET implementation of the Bayeux client protocol targeting netstandard1.1.
C#
7
star
22

stateful-roslyn-analyzer

C#
6
star
23

blackbox

A logging library inspired by log4net, targeting .NET Framework 4 Client Profile.
C#
6
star
24

tail

A minimalistic, provider based WPF version of the UNIX `tail -f` command which can handle multiple kinds of streams.
C#
4
star
25

spectre.console-di-sample

C#
4
star
26

sokoban

An attempt to write a simple game in Rust.
Rust
3
star
27

scrabbler

A scrabble library for finding word combinations from a sequence of letters provided by the user, using a word list and prefix tree.
C#
3
star
28

autorest-example

C#
2
star
29

breakout

A breakout clone
Rust
2
star
30

rustcalc

A simple experiment showing a Rust library compiled to WASM and used in a simple web page.
Rust
2
star
31

presentations

C#
2
star
32

hierarchy

An extendable tree view provider model for Windows Forms.
C#
2
star
33

blog

CSS
2
star
34

world-flags

Swift
2
star
35

swiftcalc

Swift
2
star
36

patriksvensson

C#
1
star
37

swetugg

C#
1
star
38

waithandle-rs

A library that makes signaling between threads more ergonomic.
Rust
1
star
39

table2ascii

Converts HTML tables to ASCII
C#
1
star