awesome-repositories.com
博客
MCP
awesome-repositories.com

通过 AI 驱动的搜索,发现最优秀的开源仓库。

探索精选搜索开源替代品自托管软件博客网站地图
项目MCP 服务器关于排名机制媒体报道
法律隐私政策服务条款
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
alecthomas avatar

alecthomas/kong

0
View on GitHub↗
2,976 星标·157 分支·Go·mit·6 次浏览

Kong

Kong is a declarative command line interface framework and parser for Go. It maps flags and positional arguments directly into typed Go structures using struct tags, allowing developers to define terminal interfaces through data models rather than manual parsing logic.

The project functions as a configuration mapper that populates Go structures from a combination of command-line arguments, environment variables, and JSON files. It distinguishes itself by providing a dependency injection container to pass external services into command handlers and a plugin architecture for dynamic command registration.

The framework covers a broad set of capabilities including the management of nested command hierarchies, automated context-sensitive help generation, and input validation. It also includes support for mutually exclusive flags, negatable boolean options, and lifecycle hook interception.

Features

  • CLI and Argument Parsing - Transforms raw command-line strings into typed Go data structures with automatic validation and default assignment.
  • Command-Line Argument Parsers - Provides a comprehensive system for parsing command-line flags, positional arguments, and configuration options into typed Go structs.
  • CLI Struct Mapping - Maps command line flags and positional arguments directly into typed Go structures using reflection.
  • Struct Mapping - Parses flags and arguments into a typed data structure to simplify configuration and input handling.
  • Nested Command Structures - Supports the organization of large-scale applications into nested command structures and sub-commands.
  • Declarative Argument Definitions - Allows developers to define terminal interfaces through declarative Go structures and struct tags.
  • Command Execution Logic - Invokes run methods on selected command nodes and their parents to execute the requested action.
  • Command Line Interface Frameworks - Provides a complete toolkit for building professional terminal applications with nested sub-commands and automated help.
  • Configuration Mappers - Populates Go structures by mapping inputs from command-line arguments, environment variables, and JSON files.
  • Go CLI Frameworks - Provides a Go-specific framework for mapping flags and arguments directly into typed Go structures.
  • Help Text Generators - Automatically constructs and formats instructional usage documentation based on the data model.
  • Application Configuration - Populates Go structures from environment variables and JSON files to supplement command-line flags.
  • Dependency Injection Providers - Provides a dependency injection container to pass external services and values into command handlers.
  • Struct Tags - Uses struct tags to define flag behavior, help text, and validation constraints within the data model.
  • Command-Line Interface Development - Enables building terminal applications with structured command hierarchies, flags, and positional arguments using Go structs.
  • Shared Configuration Embedding - Allows integrating external structures into the root interface to share flags across different commands.
  • Command Line Interface Plugins - Provides a plugin architecture to extend CLI tools with dynamic command registration and shared configurations.
  • Command Metadata - Provides structures for defining command names, help text, and aliases separately from the data model.
  • Runtime Command Registration - Allows the application to be extended by adding new commands at runtime.
  • Environment Variable Mapping - Populates configuration fields using environment variables with support for custom prefixes and aliases.
  • Boolean Flag Negation - Generates a corresponding disable flag for boolean options to allow users to explicitly turn off default features.
  • Configuration File Loading - Populates default values for flags and arguments from external sources like JSON files.
  • JSON Parsing - Parses a JSON source to populate flag values by mapping names to JSON keys.
  • Command Tree Traversers - Walks a hierarchical tree of commands and sub-commands to apply configuration and resolve active nodes.
  • Configuration Fallbacks - Populates missing input values with predefined defaults before validating the final configuration.
  • Custom Type Decoders - Transforms raw input strings into complex types via custom decoding interfaces implemented by the target fields.
  • Dependency Injection Containers - Includes a dependency injection container to pass external services and values into command handlers.
  • Parse Error Reporters - Provides detailed error objects with trigger context and suggested exit codes for parsing failures.
  • Extensible Plugin Architectures - Ships an extensible architecture that supports modular extensions and custom logic injection.
  • Command Lifecycle Hooks - Executes custom logic at predefined stages of the parsing process through pluggable command lifecycle hooks.
  • Modular Plugin Extensions - Integrates external structures into the application via pointers to support modular plugin functionality.
  • Parser Lifecycle Hooks - Executes custom logic at specific stages, such as before resolving arguments or after applying inputs.
  • Allowed Value Validations - Checks that loaded settings match allowed enum values or required field constraints.
  • Required Field Enforcement - Marks specific flags as required and prevents the application from running if they are missing.
  • Conflicting Argument Restrictions - Restricts the user from providing conflicting flags simultaneously to prevent invalid configurations.
  • Input Validation - Provides mechanisms for verifying structural and custom constraints on parsed commands to ensure data integrity.
  • Terminal Input Validation - Implements custom validation interfaces on command nodes to ensure arguments meet specific criteria.
  • Configuration Management - Listed in the “Configuration Management” section of the Awesome Go awesome list.
  • Command Line Tools - Struct-based command-line argument parser.
  • 配置管理 - Command-line and configuration parser.
  • Go CLI Frameworks - Library for complex command-line structures with minimal effort.

Star 历史

alecthomas/kong 的 Star 历史图表alecthomas/kong 的 Star 历史图表

AI 搜索

探索更多 awesome 仓库

用简单的语言描述您的需求 —— AI 将根据相关性为您从数千个精选开源项目中进行排序。

Start searching with AI

常见问题解答

alecthomas/kong 是做什么的?

Kong is a declarative command line interface framework and parser for Go. It maps flags and positional arguments directly into typed Go structures using struct tags, allowing developers to define terminal interfaces through data models rather than manual parsing logic.

alecthomas/kong 的主要功能有哪些?

alecthomas/kong 的主要功能包括:CLI and Argument Parsing, Command-Line Argument Parsers, CLI Struct Mapping, Struct Mapping, Nested Command Structures, Declarative Argument Definitions, Command Execution Logic, Command Line Interface Frameworks。

alecthomas/kong 有哪些开源替代品?

alecthomas/kong 的开源替代品包括: yargs/yargs — yargs is a command-line interface framework and argument parser for Node.js. It translates raw command-line strings… kelseyhightower/envconfig — envconfig is a Go configuration decoder and environment variable mapper that deserializes environment variables into… cliutils/cli11 — CLI11 is a header-only C++ library for parsing command line arguments and managing configuration files. It maps shell… spectreconsole/spectre.console — Spectre.Console is a .NET framework designed for building structured, feature-rich command-line applications. It… urfave/cli — This is a framework for building structured terminal applications in Go. It provides the core components necessary to… fastapi/typer — This project is a Python framework for building command-line interfaces by converting standard functions into…

Kong 的开源替代方案

相似的开源项目,按与 Kong 的功能重合度排序。
  • yargs/yargsyargs 的头像

    yargs/yargs

    11,492在 GitHub 上查看↗

    yargs is a command-line interface framework and argument parser for Node.js. It translates raw command-line strings into structured JavaScript objects, providing a toolkit for building terminal applications with nested sub-commands, dedicated handlers, and a structured user interface. The framework distinguishes itself through automated help text generation, which constructs formatted usage menus and instructions based on registered metadata. It also provides shell completion generation for Bash and Zsh and uses string-distance algorithms to offer typo correction suggestions when invalid inpu

    JavaScript
    在 GitHub 上查看↗11,492
  • kelseyhightower/envconfigkelseyhightower 的头像

    kelseyhightower/envconfig

    5,404在 GitHub 上查看↗

    envconfig is a Go configuration decoder and environment variable mapper that deserializes environment variables into structured Go data types. It provides tools for validating mandatory fields and ensuring application configuration adheres to the external configuration patterns of twelve-factor app compliance. The library features a help generator that creates formatted usage text based on struct definitions to describe expected environment variables. It also includes a validation tool capable of detecting unused environment variables that match a specific prefix but do not correspond to any

    Go
    在 GitHub 上查看↗5,404
  • cliutils/cli11CLIUtils 的头像

    CLIUtils/CLI11

    4,322在 GitHub 上查看↗

    CLI11 is a header-only C++ library for parsing command line arguments and managing configuration files. It maps shell input to typed variables and supports the creation of complex command hierarchies. The library is distinguished by its support for nested subcommands with infinite depth and prefix matching. It integrates configuration management by allowing application settings to be loaded from TOML or INI files, with the ability to fall back to environment variables. The project provides a comprehensive set of tools for argument parsing, including flags and positional arguments, alongside

    C++clicli-parsercpp11
    在 GitHub 上查看↗4,322
  • spectreconsole/spectre.consolespectreconsole 的头像

    spectreconsole/spectre.console

    11,210在 GitHub 上查看↗

    Spectre.Console is a .NET framework designed for building structured, feature-rich command-line applications. It provides a comprehensive toolkit for managing complex command hierarchies, type-safe argument parsing, and dependency injection, allowing developers to decouple business logic from input processing while maintaining modular application designs. The framework distinguishes itself through a sophisticated terminal user interface toolkit that enables the creation of dynamic, interactive console experiences. It utilizes a markup-based rendering system to display styled text, tables, cha

    C#ansi-colorscli-parserconsole
    在 GitHub 上查看↗11,210
  • 查看 Kong 的所有 30 个替代方案→