Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

234 Commits

Folders and files

Repository files navigation

Runic Command Line

Runic Command Line is a NativeAOT-friendly .NET command application framework. It supplies a parser-neutral catalog, typed execution, generated bindings, and predictable human or JSON output without depending on a UI framework.

Package-only quick-start

Use .NET 10. Create a console project and install the core package, which includes the source generator. This method-first example is maintained in hello-world/Program.cs.

Install the latest published release, 0.14.0, from NuGet. No source checkout or project references are needed.

dotnet new console --framework net10.0 --name HelloCli
cd HelloCli
dotnet add package Runic.CommandLine --version 0.14.0

From 0.8.0, versions are plain 0.y.z until 1.0 and install without --prerelease: a new minor may contain breaking changes, a patch only fixes or adds, and only the latest minor gets fixes.

To try the unreleased candidate from main (the version in eng/Versions.props), download the command-line-packages artifact from a successful CI run, extract it to an absolute directory and add the package from there instead: dotnet add package Runic.CommandLine --version <candidate> --source /absolute/path/to/candidate-feed. CI checks this tutorial against the candidate packages.

Replace Program.cs with:

using Runic.CommandLine;
using Runic.CommandLine.Generated;

return await new CommandApp(GeneratedCommandCatalog.Create()) { Name = "hello" }.RunAsync(args);

internal static class Commands
{
    [Command("greet", Description = "Say hello."), DefaultCommand]
    internal static string Greet([Argument] string name = "world",
        [Option("--count", "-n", Minimum = 1, Maximum = 100)] int count = 1) =>
        string.Join('\n', Enumerable.Repeat($"Hello, {name}!", count));
}

Run the same command in human and machine mode:

dotnet run -- Ada --count 2
dotnet run -- Ada --count 2 --format=json
dotnet run -- --help

Human output is two Hello, Ada! lines. JSON output is one runic.commandline/1 envelope with success: true and a string payload containing those lines. Release 0.8.0 spells the output selector --format; the earlier 0.7.0-preview.2 spelled it --output (see the release notes). The built-in string codec supplies both formats; no JSON context is needed here.

JSON output is UTF-8. Windows PowerShell 5.1 decodes a native program's output with the console's OEM code page unless the caller sets [Console]::OutputEncoding, so Räume arrives as Räume; a tool that such callers run sets JsonOutput = new CommandJsonOutputOptions { Escaping = CommandJsonEscaping.Ascii } on its CommandApp to write pure ASCII. The package README also covers a JSON document for every outcome and an empty standard error.

For another published release, choose a version listed on NuGet and consult that package's README for its supported API. Optional packages must use the same Command Line version.

Package Purpose
Runic.CommandLine Contracts, catalog, parsing, execution, hosting, output, and embedded source generator.
Runic.CommandLine.Processes Bounded local process execution.
Runic.CommandLine.Spectre Spectre.Console presentation adapter.
Runic.CommandLine.Testing Deterministic in-memory test helpers.

Start with the examples and the protocol and grammar specifications. Each published package also contains its own API-oriented README.

Develop

The repository pins .NET in global.json. On NixOS, inspect .envrc and flake.nix, then use the pinned environment explicitly:

direnv allow
direnv exec . ./eng/verify.sh

eng/test.sh runs the managed suites and examples; the suites use TUnit, and CONTRIBUTING.md explains how to run, filter and report them. eng/verify.sh additionally runs the NativeAOT source smoke and an isolated consumer against the packed packages. It reads the candidate version from eng/Versions.props, or accepts ./eng/verify.sh <version> [package-directory] [runtime-identifier]. NativeAOT defaults to the host runtime. ./eng/verify-candidate.sh with the same arguments packs and checks only the candidate packages. Packing builds the set in a staging directory and replaces the output directory only when every package succeeded, so a failed or interrupted pack keeps the previous set. CI packs once and runs source and candidate consumer NativeAOT checks on Linux x64 and Arm64 (glibc and musl), Windows x64 and Arm64 and macOS Arm64. Pull requests and ordinary pushes to main run the Windows and macOS jobs only when they change a path that can behave differently there; see CONTRIBUTING.md.

Each package tracks its public API in PublicAPI.Shipped.txt (the last published release) and PublicAPI.Unshipped.txt (changes since then), checked by Microsoft.CodeAnalysis.PublicApiAnalyzers. A verification build fails on an undeclared API change: add new members to PublicAPI.Unshipped.txt (the IDE code fix for RS0016 does this) and mark removals with *REMOVED*. Packing also runs package validation against the release in RunicCommandLinePackageValidationBaselineVersion (eng/Versions.props). After a release, move the unshipped entries into the shipped files and advance the baseline.

Changes reach main through pull requests. The verify job in CI always reports and passes only when every other CI job passed, or a macOS job was skipped because the pull request changes none of its paths; it is the check to require before merging. CI also lints workflows with actionlint and requires remote actions pinned to a full commit SHA followed by a # vX.Y.Z comment; update both together from the tag's commit. A first-party reusable workflow (runic-sdk's train gate) is pinned to a full commit SHA with a comment that names that commit. Report vulnerabilities as described in SECURITY.md.

Releases

The four NuGet package identities release together, independently from the Runic SDK. See the release guide. The latest published release is 0.14.0, part of the 0.23 release train with Runic Translations 0.15.0 and Runic SDK 0.23.0; see its upgrade notes. The next release is 0.15.0 (its upgrade notes), part of the 0.24 release train with Runic Translations 0.16.0 and Runic SDK 0.24.0. The 1.0.0-rc.N release candidates follow once a pull request schedules them; they take only fixes, and 1.0.0 follows the last one. The packages keep their Runic.* identities. Until 1.0 releases use plain 0.y.z versions, where a new minor may break and a patch only fixes or adds, and are still marked as prereleases on GitHub, as the release candidates are. The first standalone release was 0.6.0-preview.2; consumers on earlier SDK previews may retain their pinned versions until they adopt a newer release.

History

This repository was extracted from Runic-Artifex/runic-sdk at source commit e6de9ca3c6073aae33dc5fadbe6ebd5ec3de58df. Its history contains only Command Line product paths, including legacy WebUIToolkit.CommandLine* and RunicCommandLine* namespaces. No SDK release tags were carried forward.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages