Skip to content

Commit

Permalink
README: update
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Apr 13, 2022
1 parent 3ea089d commit 6c73ed8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 42 deletions.
37 changes: 12 additions & 25 deletions README.md
@@ -1,20 +1,27 @@
# Mirai Console Loader

模块化、轻量级且支持完全自定义的 [mirai](https://github.com/mamoe/mirai) 加载器。
[![GitHub release](https://img.shields.io/github/v/release/itxtech/mirai-console-loader?label=stable)](https://github.com/iTXTech/mirai-console-loader/releases)
[![Maven Central](https://img.shields.io/maven-central/v/org.itxtech/mcl)](https://repo.maven.apache.org/maven2/org/itxtech/mcl/)
[![MiraiForum](https://img.shields.io/badge/post-on%20MiraiForum-yellow)](https://mirai.mamoe.net/topic/177)

欢迎阅读命令行参数的[说明](cli.md),它将教会你如何`安装插件``禁用和启用脚本``修改包的更新频道`等基本操作
模块化、轻量级且支持完全自定义的 [mirai](https://github.com/mamoe/mirai) 加载器

开发者请参见 [MCL 开发文档](docs/README.md)

## 简介

`iTX Technologies Mirai Console Loader`(下简称`MCL`)采用模块化设计,包含以下几个基础模块:

* `Script` 脚本执行模块,用于加载和执行脚本`MCL`的主要功能均由脚本实现。脚本执行有各个阶段,详见注释
* `Module` 模块管理器,用于加载和执行模块`MCL`的主要功能均由模块实现。模块执行有各个阶段,详见开发文档
* `Config` 配置文件模块,用于配置的持久化。
* `Package` 包管理器。
* `Downloader` 下载器模块,用于下载文件,并实时返回进度。
* `Logger` 日志模块,用于向控制台输出日志。

## [`MCL` 命令行文档](cli.md)

该文档将教会您如何`安装插件``禁用和启用脚本``修改包的更新频道`等操作。

## 使用 `iTXTech MCL`

### 一键安装
Expand All @@ -28,7 +35,7 @@
3. 解压到某处
4. 在命令行中执行`.\mcl`以启动`MCL`

`*nix`下通过命令行安装
#### `*nix`下通过命令行安装

```bash
$ java -version # Check your java installation
Expand All @@ -41,31 +48,11 @@ $ chmod +x mcl
$ ./mcl
```

### 禁用控制台颜色

配置`mcl.disable-ansi`环境变量为`true`

```bash
$ java "-Dmcl.disable-ansi=true" -jar mcl.jar
```

仅禁用 `Windows CMD``ANSI` 初始化,请配置 `mcl.no-ansi-console-init` 环境变量为 `true`

### 切换 `Mirai Repo`

`MCL` 内置 `Mirai Repo Manager`,可通过以下命令调用。

```bash
$ ./mcl --mrm-list # 列出内置 Mirai Repo
$ ./mcl --mrm-use forum # 使用 Mirai Forum 提供的 Mirai Repo 镜像
$ ./mcl --set-mirai-repo https://repo.example.org # 使用自定义的 Mirai Repo
```

## `Mirai Repo` 列表

* [iTXTech](https://repo.itxtech.org) - **默认** - Cloudflare Pages
* [Mamoe](https://mcl.repo.mamoe.net) - GitHub Pages
* [GitHub](https://github.com/project-mirai/mirai-repo-mirror) - 如要镜像请完整拷贝该仓库文件即可
* [GitHub](https://github.com/project-mirai/mirai-repo-mirror) - 源仓库

## `Maven Repo` 列表

Expand Down
69 changes: 55 additions & 14 deletions cli.md
Expand Up @@ -4,47 +4,85 @@

此功能可以自动从`Maven Repo`获取最新版本。

`.\mcl --update-package 包名 --channel maven`
```
.\mcl --update-package 包名 --channel maven
```

### `maven` 支持两个子频道

* `stable` - 稳定版 - `.\mcl --update-package 包名 --channel maven-stable`
* `prerelease` - 预发行版 - `.\mcl --update-package 包名 --channel maven-prerelease`
* 留空或其他,则默认为最新版

## 禁用控制台颜色

配置`mcl.disable-ansi`环境变量为`true`

```bash
$ java "-Dmcl.disable-ansi=true" -jar mcl.jar
```

仅禁用 `Windows CMD``ANSI` 初始化,请配置 `mcl.no-ansi-console-init` 环境变量为 `true`

## 切换 `Mirai Repo`

`MCL` 内置 `Mirai Repo Manager`,可通过以下命令调用。

```bash
$ ./mcl --mrm-list # 列出内置 Mirai Repo
$ ./mcl --mrm-use forum # 使用 Mirai Forum 提供的 Mirai Repo 镜像
$ ./mcl --set-mirai-repo https://repo.example.org # 使用自定义的 Mirai Repo
```

## 使用样例

* 修改某个包的更新频道

`.\mcl --update-package 包名 --channel 频道名`
```
.\mcl --update-package 包名 --channel 频道名
```

* 安装 `Mirai Native`

`.\mcl --update-package org.itxtech:mirai-native --type plugin --channel stable`
```
.\mcl --update-package org.itxtech:mirai-native
```

* 安装 `Chat Command`

`.\mcl --update-package net.mamoe:chat-command --type plugin --channel stable`
```
.\mcl --update-package net.mamoe:chat-command
```

* 指定 `mirai-console` 版本(指定的版本必须为该`Channel`中存在的版本)

`.\mcl --update-package net.mamoe:mirai-console --channel stable --version 1.0.0`
```
.\mcl --update-package net.mamoe:mirai-console --channel stable --version 1.0.0
```

* 忽略版本更新
* 执行包更新

`.\mcl -u`
```
.\mcl -u
```

* 禁用`updater`脚本
* 禁用 `updater` 模块

`.\mcl --disable-script updater`
```
.\mcl --disable-module updater
```

* 启用 `updater` 脚本
* 启用 `updater` 模块

`.\mcl --enable-script updater`
```
.\mcl --enable-module updater
```

* 更新运行库但不启动

`.\mcl --dry-run`
```
.\mcl --dry-run
```

* 查看帮助

Expand All @@ -54,11 +92,12 @@ PS > .\mcl -h
usage: mcl
-a,--update-package <PackageName> Add or update package
-b,--show-boot-props Show Mirai Console boot properties
--boot-only Execute boot phase only
-c,--log-level <level> Set log level
-d,--disable-module <ModuleName> Disable module
--disable-auto-clear Disable Repo With Cache auto clear
--disable-auto-clear Disable Repo Cache auto clear
-e,--enable-module <ModuleName> Enable module
--enable-auto-clear Enable Repo With Cache auto clear
--enable-auto-clear Enable Repo Cache auto clear
-f,--set-boot-entry <EntryClass> Set Mirai Console boot entry
-g,--set-boot-args <Arguments> Set Mirai Console boot arguments
-i,--package-info <PackageName> Fetch info for specified package
Expand All @@ -74,6 +113,8 @@ usage: mcl
-q,--delete Remove outdated files while updating
-r,--remove-package <PackageName> Remove package
-s,--list-packages List configured packages
--set-max-threads <MaxThreads> Set Max Threads of Multithreading
Downloader
-t,--type <Type> Set type of package
-u,--update Update packages
-w,--version <Version> Set version of package
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/itxtech/mcl/module/builtin/MDownloader.java
Expand Up @@ -61,17 +61,17 @@ public void cli() {
loader.logger.error("Invalid Max Threads value");
}
}
loader.downloader = new MultithreadDownloaderImpl(loader.downloader,
loader.downloader = new MultithreadingDownloaderImpl(loader.downloader,
Integer.parseInt(loader.config.moduleProps.getOrDefault(MAX_THREADS_KEY, "16")));
}

public static class MultithreadDownloaderImpl implements Downloader {
public static class MultithreadingDownloaderImpl implements Downloader {
private static final int MIN_SIZE = 2 * 1024 * 1024; // < 2MB

private int maxThreads;
private Downloader defaultDownloader;

public MultithreadDownloaderImpl(Downloader defaultDownloader, int maxThreads) {
public MultithreadingDownloaderImpl(Downloader defaultDownloader, int maxThreads) {
this.maxThreads = maxThreads;
this.defaultDownloader = defaultDownloader;
}
Expand Down

0 comments on commit 6c73ed8

Please sign in to comment.