patriksvensson / dotnet-example

A dotnet tool to list and run examples
MIT License
170 stars 15 forks source link

Example list is sorted differently on Windows and Linux #7

Open alexrp opened 2 years ago

alexrp commented 2 years ago

Repro:

$ git clone git@github.com:alexrp/system-terminal.git
$ cd system-terminal
$ dotnet example

Windows output:

$ dotnet example

┌──────────────┬─────────────┐
│ Example      │ Description │
├──────────────┼─────────────┤
│ attributes   │             │
│ cancellation │             │
│ cursor       │             │
│ extensions   │             │
│ hosting      │             │
│ processes    │             │
│ raw          │             │
│ resize       │             │
│ screens      │             │
│ scrolling    │             │
│ signals      │             │
│ width        │             │
└──────────────┴─────────────┘

Type dotnet example --help for help

Linux output:

$ dotnet example

╭──────────────┬─────────────╮
│ Example      │ Description │
├──────────────┼─────────────┤
│ processes    │             │
│ cursor       │             │
│ extensions   │             │
│ screens      │             │
│ scrolling    │             │
│ width        │             │
│ attributes   │             │
│ resize       │             │
│ hosting      │             │
│ cancellation │             │
│ signals      │             │
│ raw          │             │
╰──────────────┴─────────────╯

Type dotnet example --help for help
patriksvensson commented 2 years ago

@alexrp Yes, the order is up to how the OS enumerates files and directories. If you want to set a specific order for your examples, you can set the <ExampleOrder> MSBuild property in your example.

i.e:

<ExampleOrder>5</ExampleOrder>
alexrp commented 2 years ago

What do you think about sorting by name first and then by ExampleOrder?

I suspect a lot of people would like alphabetical sorting anyway, and maintaining ExampleOrder values across multiple projects to achieve that is a bit of a pain, especially in an evolving project. People who want a specific ordering could still override it as before.