Modulight.Modules.CommandLine
0.0.7
.NET 5.0
dotnet add package Modulight.Modules.CommandLine --version 0.0.7
NuGet\Install-Package Modulight.Modules.CommandLine -Version 0.0.7
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Modulight.Modules.CommandLine" Version="0.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Modulight.Modules.CommandLine --version 0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Modulight.Modules.CommandLine, 0.0.7"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Modulight.Modules.CommandLine as a Cake Addin
#addin nuget:?package=Modulight.Modules.CommandLine&version=0.0.7
// Install Modulight.Modules.CommandLine as a Cake Tool
#tool nuget:?package=Modulight.Modules.CommandLine&version=0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Modulight.Modules.CommandLine
class Program
{
public static async Task Main(string[] args) => await CreateHostBuilder(args).RunConsoleAsyncWithModules();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddModules(builder =>
{
builder.UseCommandLineModules().AddModule<AModule>();
});
});
}
[Command]
public class LogCommand : ModuleCommand<AModule>
{
public LogCommand(AModule module) : base(module)
{
}
// Order: 0
[CommandParameter(0, Description = "Value whose logarithm is to be found.")]
public double Value { get; init; }
// Name: --base
// Short name: -b
[CommandOption("base", 'b', Description = "Logarithm base.")]
public double Base { get; init; } = 10;
protected override ValueTask ExecuteAsync(IConsole console, CancellationToken cancellationToken = default)
{
var result = Math.Log(Value, Base);
console.Output.WriteLine(result);
console.Output.WriteLine($"From Module {Module.Manifest.DisplayName}.");
return default;
}
}
[CommandFrom(typeof(LogCommand))]
public class AModule : CommandLineModule
{
public AModule(IModuleHost host) : base(host)
{
}
}
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- CliFx (>= 2.0.4)
- Microsoft.Extensions.Hosting (>= 5.0.0)
- Modulight.Modules.Core (>= 0.0.7)
- Modulight.Modules.Hosting (>= 0.0.7)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.7 | 314 | 5/31/2021 |
0.0.7-preview.8 | 232 | 5/30/2021 |
0.0.1 | 344 | 5/30/2021 |