搜索插件、代码仓与 APP 分类

插件详情v0.3.4+1

cli_launcher

CLI 开发工具,用于支持启动本地安装的版本。

AndroidiOSLinuxmacOSWindows
近 30 天下载
106万
喜欢数
5
Pub 分数
160

安装插件

flutter pub add cli_launcher

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个用于简化在开发过程中启动本地安装的命令行工具的 Flutter/Dart 包。它支持在 Flutter 应用内无缝执行 CLI 工具,适用于 Android、iOS、Linux、macOS 和 Windows 的跨平台工作流。对于需要集成或调用外部命令行程序的开发者而言,该包通过管理本地安装和执行路径,简化了测试和调试流程。在需要直接访问系统级命令的开发环境中尤为有用。

适合场景

  • 在应用开发期间启动本地 CLI 工具
  • 将外部命令行工具集成到Flutter应用中
  • 在受控环境中测试命令行交互
  • 在Flutter应用中自动化构建或部署脚本
  • 支持依赖本地可执行文件的开发工具链

主要特点

  • 跨平台 CLI 执行支持
  • 轻松集成本地安装的工具
  • 可执行文件的自动路径解析
  • 用于启动命令的简单 API
  • 命令失败的内置错误处理

适合对象

  • 使用 CLI 工具的 Flutter 开发人员
  • 需要与系统命令集成的工具
  • 需要本地命令执行的开发环境
  • Flutter 项目中的构建和自动化脚本
  • 使用自定义或第三方 CLI 工具的团队

使用建议

  • 需要正确的权限才能执行系统命令
  • 可能需要平台特定的配置
  • 不适用于 CLI 工具的生产分发
  • 仅限本地安装,不支持远程执行
  • 依赖主机系统上目标 CLI 工具的正确配置

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

CI Pub Version

CLI development utility to support launching locally installed versions.

When the globally installed version of a CLI is launched and it finds a locally installed version of itself that is a different version, it will launch the locally installed version.

Otherwise, the globally installed version will continue to run.

Installing means adding the package that contains the CLI executable to a pubspec.yaml file.

To find the locally installed version, the globally installed version will search for a pubspec.yaml file in the current directory or any parent directory. If it finds one, it will look for a dependency on the package that contains the CLI executable.

In addition, if the CLI is executed in the package that contains the CLI executable, the current version in that package will be launched. This is useful for development.

Launch flow

flowchart TD
    A["User invokes CLI"] --> B["launchExecutable()"]
    B --> C{"Launch context<br/>in args?"}

    C -- "Yes (relaunched by global)" --> D["Restore original working<br/>directory, call entrypoint"]
    C -- "No (initial invocation)" --> E["Detect global installation<br/>from Platform.script"]

    E --> F["Search for local installation<br/>(walk up from cwd, check pubspec.yaml<br/>for dependency or dev_dependency)"]

    F -- "Found" --> G{"pubspec.lock<br/>up to date?"}
    F -- "Not found" --> GLOBAL

    G -- "Yes" --> I
    G -- "Missing or<br/>older than<br/>pubspec.yaml" --> H["Run pub get from<br/>lock file root"]

    H -- "OK" --> I{"Source package,<br/>path dep, or<br/>version mismatch?"}
    H -- "Failed" --> EXIT["Exit with error"]

    I -- "No" --> GLOBAL["Run entrypoint<br/>with global installation"]
    I -- "Yes" --> J["Launch local via<br/>dart run package:executable<br/>(inject launch context in args)"]

    J --> K["New process starts,<br/>calls launchExecutable(),<br/>finds launch context in args"]
    K --> D

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。

所在榜单