-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Design] KCL CLI UI and Workflow #756
Comments
In the UI design, it is necessary to consider environment variables. Users may need to adjust kpm through environment variables in some scenarios. For example, the current commands do not provide a mechanism for adjusting the registry, so users may need to change the default registry through environment variables. |
Something I've considered in my previous job that might be usefulConsiderations for deciding which functionalities to support through environment variables:
An additional implementation consideration
|
Issues that need further clarification
|
Summary
This document mainly provides the overall command line user interface of kcl lang, including the types and forms of commands, as well as how users can use the command line provided by kcl lang to complete scene functions.
Motivation
As shown in https://kcl-lang.io/docs/community/release-policy/kcl, we have already provided many languages, toolchain CLIs, and APIs related to KCL and KPM in advance, such as kcl, kcl-go, kcl-lint, kcl-fmt, kpm kcl-openapi, etc. Developer may be confused when to use them. We need to provide a unified CLI, API framework and implementation to maintain scalability, and provide unified documentation in v0.7.0.
Goals
Non-Goals
Proposals
Standardize command structure: Define a consistent structure for commands across different KCL tools and APIs. This includes specifying the format for command invocation, options, and arguments. The aim is to provide a clear and predictable command structure that is easy for users to understand and follow.
Introduce a unified CLI tool: Develop a unified CLI tool, called "kcl", which serves as the entry point for accessing various KCL tools and functionalities. The kcl CLI will provide a set of high-level commands that cover common package management tasks, such as package creation, installation, publishing, and dependency management. This will simplify the user workflow and reduce the need for users to remember and use different command names for different tools.
Implement comprehensive help and documentation: Include detailed help messages and documentation for each command, providing clear explanations of command usage, available options, and examples. The help messages should follow a consistent format and should be easily accessible to users when needed. This will enable users to quickly understand and utilize the capabilities of each command without relying on external documentation or resources.
Enable extensibility: Design the CLI in a modular and extensible manner, allowing for the integration of additional tools, APIs, and functionality in the future. Provide clear guidelines and interfaces for extending the CLI, enabling developers to contribute new commands, plugins, or integrations. This will foster community involvement and allow the CLI to evolve and adapt to the changing needs of the KCL ecosystem.
Support automation and scripting including GitHub action components, etc.
Design Details
KCL Tool
Language & Tooling Commands
Package & Registry Related Commands (mod and registry workspace)
Integration Commands
Plugin Commands (plugin workspace)
Version and Help Commands
Subcommands Lifecycle
plugin.yaml
file in the subcommand Git repository to declare the download URL and version of plugin commands. Thekcl plugin
command can recognize the plugin. yaml file and install the corresponding plugin commands.CLI Structure
Commands should follow a consistent structure of kcl [command] [options] [arguments]. Options should use standard conventions like short flags (e.g., -v for verbose) and long flags (e.g., --version).
The interface should provide informative and user-friendly error messages for incorrect command usage or failures. The command line interface should provide extensive inline help and documentation for each command, accessible through the following command
Help Message
The help information in a command line typically includes the following:
Environment Variables
https
/http
Unified SDK & API
The
kcl-go
,kpm
,kcl-playground
, andkcl-openapi
repos will be unified into one kcl-go repo for the following reasons:CLI Framework
Design Detail is in #741, we won't go into detail here.
User Stories
Producer
As a KCL package producer, I want to be able to create a new KCL package easily using the command line interface. I should be able to specify the package name, version, and other relevant metadata during the creation process.
As a KCL package producer, I want to be able to add dependencies to my KCL package using the command line interface. I should be able to specify the dependencies and their versions, and the CLI should handle the installation and management of these dependencies.
As a KCL package producer, I want to be able to test, lint and format my KCL package code using the command line interface. The CLI should provide commands to run linters and formatters on my package code, helping me maintain code quality and consistency.
As a KCL package producer, I want to be able to publish my KCL package to a registry or repository using the command line interface. The CLI should handle the necessary authentication and package publishing process, allowing me to easily share my package with others.
Consumer
As a KCL package consumer, I want to be able to search for available KCL packages using the command line interface. The CLI should provide a command to search for packages based on keywords, allowing me to find relevant packages for my project.
As a KCL package consumer, I want to be able to install KCL packages into my project using the command line interface. The CLI should provide a command to specify the package name and version, and handle the installation and dependency resolution process automatically.
As a KCL package consumer, I want to be able to update installed KCL packages to newer versions using the command line interface. The CLI should provide a command to check for package updates and handle the update process, ensuring that my project is using the latest versions of the packages.
As a KCL package consumer, I want to be able to generate documentation for installed KCL packages using the command line interface. The CLI should provide a command to generate documentation based on the package code and metadata, helping me understand and utilize the package's functionality.
Risks and Mitigations
Alternatives
Language-specific CLIs
Language-specific CLIs: Instead of a unified command line interface, each tool (e.g., kcl-fmt, kcl-lint) could have its own dedicated CLI tool. This would allow for more specialization and tailored experiences for each language, but it may result in fragmentation and confusion for users who work with multiple KCL languages and tools. It would require users to learn and remember different commands and workflows for each language-specific CLI.
Integration with existing package managers
Integration with existing package managers: Rather than introducing a new CLI tool (kcl), the KCL functionality could be integrated with existing package managers like npm, pip, or Maven. This would leverage the familiarity and usage of these package managers and provide a unified experience for users who are already using these tools. However, it may introduce dependencies and limitations imposed by the existing package managers, potentially limiting the flexibility and extensibility of the KCL ecosystem.
Different CLI Workspaces
Tasks
The text was updated successfully, but these errors were encountered: