dotnet / dotnet/command-line-api

Support metadata based CLI: was Demo/test case: TaskRunner parsing

Open
#461 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

Imagine an exe called TaskRunner.dll that has a bunch of `TaskDefinition` sub-classes.

I would like to provide dotnet-suggest support for each one. To do this, I would need to load, using reflection, an instance of each `TaskDefinition` and be able to explain to `System.CommandLine` how to use this metadata to provide command line auto-completion suggestions.

```
public interface ITaskDefinition { string Key { get; } }
public abstract class TaskDefinitionBase : ITaskDefinition where T : ITask
{
public abstract string Key { get; }
}
public class CleanFullTaskDefinition : TaskDefinition
{
public override string Key => "cleanfull";
}
public class SqlExecuteTaskDefinition : TaskDefinition
{
public override string Key => "sqlcmd";
}
public class FluentMigratorTaskDefinition : TaskDefinition
{
public override string Key => "fm";
}
// etc, 1,000s of tasks to build Gilles Tréhin's Urville :)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.