Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

ApplicationBuilderHelpers

Build command-line apps in .NET with plain classes. Mark a class as a command, add options and arguments as properties, then run it.

  • Targets: net6.0 through net10.0 · AOT-ready on net8.0+ · Trimmable
  • Packages: Microsoft.Extensions.Hosting, Microsoft.Extensions.DependencyInjection.Abstractions, AbsolutePathHelpers

Features

  • Commands with automatic parsing. You write a class. The library reads the arguments.
  • Services in your command. Ask for a service. The library provides it.
  • Shared setup modules. Group common services once. Reuse them in every app.
  • App settings that reuse another key with @ref: — see Configuration.
  • Command markers: [Command], [CommandOption], [CommandArgument].
  • Subcommands like deploy prod. Nest as deep as you need.
  • Styled --help with 6 color themes and adjustable width.
  • Console and web hosts. Use the default for CLIs. Plug in your own for servers.

Installation

dotnet add package ApplicationBuilderHelpers

Quick Start

New here? Follow Getting Started for a full Hello sample. It prints Hello, Alice! and exits 0. Prefer a full starter app? See Starter Templates.

RunAsync returns an exit code: 0 success, 2 bad input, 1 failure, 130 canceled. See Commands.

Core Concepts

Extend Command and override Run. Add options with [CommandOption] and positionals with [CommandArgument]. Put shared setup in Application Dependencies.

Exit codes: 0 means success, 2 means bad input, 1 means failure, 130 means canceled. See API Reference.

How a Run Works

Shared setup → Command → Host build → Services → Your Run method
  1. You register commands and shared setup modules.
  2. The library builds the host once per run.
  3. The library fills your options, arguments, and services.
  4. Your Run method executes.

The full order of the 8 shared setup steps lives in Application Dependencies.

Documentation

Guide Covers
Getting Started Install, minimal app, first command, run it
Starter Templates Copy-only Plain CLI, WebApi, or WebApiAndWebApp starter
Commands Commands, options, arguments, services, completion
Application Dependencies Shared setup modules
Configuration & Themes App name, help width, themes, @ref: settings
Custom Type Parsers Support your own option types
Advanced Topics Subcommands, web hosts, errors, help
API Reference Every public class and method

Secret values stay hidden. Help, errors, and completions never print them.

Contributing

Contributions are welcome! Please submit a Pull Request.

License

MIT — see the LICENSE file.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages