• Stars
    star
    155
  • Rank 232,825 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 3 years ago
  • Updated 3 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

ghostly

Ghostly is a GitHub notification client for Windows 10/11
C#
283
star
2

machine

Contains my install scripts and configurations for Windows and Linux
PowerShell
79
star
3

wisp

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

covenant

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

mew-prototype

A research project for building a compiler in C#
C#
46
star
6

license-key

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

autograph

A utility that creates dot graphs from .NET projects
C#
37
star
8

get-the-fork-out

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

dotnet-release-artifacts

C#
13
star
10

spdx

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

rosetta

C#
12
star
12

ntiled

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

bytestream-rs

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

hush

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

bayeux

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

spectre-kit

A Swift framework that makes it easier to create beautiful console applications.
Swift
6
star
17

blackbox

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

stateful-roslyn-analyzer

C#
5
star
19

tail

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

sokoban

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

spectre.console-di-sample

C#
3
star
22

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
23

autorest-example

C#
2
star
24

breakout

A breakout clone
Rust
2
star
25

rustcalc

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

presentations

C#
2
star
27

hierarchy

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

blog

CSS
2
star
29

world-flags

Swift
2
star
30

swiftcalc

Swift
2
star
31

patriksvensson

C#
1
star
32

swetugg

C#
1
star
33

waithandle-rs

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

table2ascii

Converts HTML tables to ASCII
C#
1
star