Skip to content

Commit

Permalink
refactor: 🚚 初步CLI拆分
Browse files Browse the repository at this point in the history
从BabelNAR.rs中拆分出BabelNAR-CLI.rs,以分离程序依赖
  • Loading branch information
ARCJ137442 committed Sep 12, 2024
1 parent 43d492d commit 2357f6f
Show file tree
Hide file tree
Showing 107 changed files with 29 additions and 10,076 deletions.
106 changes: 14 additions & 92 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
[package]
name = "babel_nar"
version = "0.25.3"
name = "babel_nar_cli"
version = "0.1.0"
edition = "2021"
description = """
Implementation and application supports of the NAVM model
Command Line Interface (CLI) of BabelNAR.rs
"""

readme = "README.md" # ! ⚠️↓crates.io的每个关键词长度不能超过20字符
keywords = ["NARS", "Non-Axiomatic-Logic", "NAVM"]
keywords = ["NARS", "NAVM", "BabelNAR"]

license = "MIT OR Apache-2.0"
categories = [
"parser-implementations", # 解析器实现 | 各CIN方言
"development-tools", # 开发工具
"command-line-utilities", # CLI应用
] # 🔗<https://crates.io/category_slugs>
repository = "https://github.com/ARCJ137442/BabelNAR.rs"
repository = "https://github.com/ARCJ137442/BabelNAR-CLI"

# Cargo文档参考:<https://rustwiki.org/zh-CN/cargo/reference/manifest.html>

Expand Down Expand Up @@ -59,123 +57,47 @@ version = "0.17" # 现已发布于`crates.io`
# ! 【2024-03-23 19:19:01】似乎Rust-Analyzer无法获取私有仓库数据
features = [] # ! 【2024-03-21 09:24:51】暂时没有特性

[dependencies.babel_nar]
version = "0.25"
features = ["bundled"]

## 依赖特性的可选依赖 ##

# Rust版本的正则表达式
# * 🎯用于解析提取NARS输出
# * 📄OpenNARS、ONA、PyNARS
[dependencies.regex]
version = "1.10.6"
optional = true

# 用于实现「静态含闭包常量」
# * 🎯初次引入:NARS-Python 方言格式
# * 🔗:https://stackoverflow.com/questions/73260997/rust-boxed-closure-in-global-variable
[dependencies.lazy_static]
version = "1.4.0"
optional = true

# Rust版本的PEG解析器
# * 🎯用于对接一些NARS方言的解析
# * 📄OpenNARS(操作语法)、ONA(中缀语法)
[dependencies.pest]
version = "2.7.8"
optional = true

# Rust版本的PEG解析器(派生宏)
[dependencies.pest_derive]
version = "2.7.12"
optional = true

# 命令行支持/彩色终端
[dependencies.colored]
version = "2.1.0"
optional = true

# 命令行支持/(H)JSON配置解析
[dependencies.serde]
version = "1.0.210"
optional = true
features = ["derive"]

[dependencies.serde_json]
version = "1.0.128"
optional = true

[dependencies.deser-hjson]
version = "2.2.4"
optional = true

# 命令行支持/Websocket服务
[dependencies.ws]
version = "0.9.2"
optional = true

# 命令行支持/命令行参数解析
[dependencies.clap]
version = "4.5.17"
features = ["derive"]
optional = true

### 定义库的特性 ###
[features]

## 默认启用的特性 ##
default = [ "bundled" ] # * 默认启用所有(可选禁用)
## 大杂烩 ##
bundled = [
"cin_implements", # 各大CIN的NAVM实现
"cli_support", # 命令行支持
"test_tools", # 测试工具集
]

## 各个独立的特性 ##

# 具体接口实现(虚拟机启动器) #
# ✅OpenNARS
# ✅ONA
# ✅PyNARS
# ✅NARS-Python(不稳定)
# ✅OpenJunars(不稳定)
cin_implements = [
"opennars",
"ona",
"pynars",
"nars_python",
"openjunars",
]
# ✅OpenNARS接口
opennars = [
"regex",
"pest", "pest_derive",
]
# ✅ONA接口
ona = [
"regex",
"pest", "pest_derive",
]
# ✅PyNARS接口
pynars = [
"regex",
# "pest", # ! 【2024-03-27 20:52:17】无需特别解析方言:其输出即为CommonNarsese
]
# ✅NARS-Python接口(不稳定)
nars_python = [
"lazy_static", # 这个「词法Narsese」也在用
]
# ✅OpenJunars接口(不稳定)
openjunars = []

# 命令行支持 #
cli_support = [
"colored", # 命令行io 彩色打印
"serde", "serde_json", "deser-hjson", # 配置文件解析
"ws", # 命令行io Websocket服务
"clap" # 命令行参数解析
]

# 测试工具集 #
test_tools = [
# 统一`.nal`格式
"pest", "pest_derive",
]
# * 🚩【2024-09-12 16:27:50】暂时没有需要启用的特性
# ## 默认启用的特性 ##
# default = [ "bundled" ] # * 默认启用所有(可选禁用)
# ## 大杂烩 ##
# bundled = []
52 changes: 8 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BabelNAR.rs
# BabelNAR-CLI.rs

简体中文 | [English](./README.en-us.md)

Expand All @@ -8,12 +8,9 @@

该项目使用[语义化版本 2.0.0](https://semver.org/)进行版本号管理。

[**NAVM.rs**](https://github.com/ARCJ137442/NAVM.rs)[CIN](#cin-computer-implement-of-nars)**启动器****运行时**及应用程序实现
[**BabelNAR.rs**](https://github.com/ARCJ137442/NAVM.rs)的命令行接口(CLI)

- 前身为[**BabelNAR.jl**](https://github.com/ARCJ137442/BabelNAR.jl)
- ✨为「非公理虚拟机模型」提供程序实现
- ✨统一各[CIN](#cin-computer-implement-of-nars)**输入输出**形式,聚合使用各大NARS实现
- ✨提供一个方便使用的CLI工具,以便从配置中快速启动、测试各类NARS实现
- ✨从配置中快速启动、测试各类NARS实现
- 🎯一站式NARS**启动器**
- 🎯NARS**交叉测试**工具

Expand All @@ -23,45 +20,14 @@

## 使用

### CLI

- 使用 JSON/HJSON 配置文件 (`.json`/`.hjson`)
- 格式可参考项目测试代码
- 依照使用 JSON/HJSON 配置文件 (`.json`/`.hjson`)
- 格式可参考
- `config_public` 中的配置文件
- 项目测试代码
- Rust调用侧:可参考项目测试代码

🏗️TODO(接受贡献)

## 概念

### CIN (Computer Implement of NARS)

- 「NARS计算机实现」之英文缩写
- 指代所有**实现NARS**的计算机软件系统
- 不要求完整实现NAL 1~9

### ***CommonNarsese***

🔗参考[**NAVM.jl**的对应部分](https://github.com/ARCJ137442/navm.jl?tab=readme-ov-file#commonnarsese)

## 各CIN对接情况

🕒最后更新时间:【2024-03-26 01:43:28】

| CIN | 实现方法 | 进程安全 | 输入转译 | 输出转译 |
| :---------- | :---------: | :--: | :--: | :--: |
| OpenNARS | `java -jar` ||| 🚧 |
| ONA | 直接启动exe ||| 🚧 |
| PyNARS | `python -m` || 🚧 | 🚧 |
| NARS-Python | 直接启动exe ||||
| OpenJunars | `julia` ||||

注:

- 🚧输入输出转译功能仍然在从[BabelNAR_Implements](https://github.com/ARCJ137442/BabelNAR_Implements.jl)迁移
- ❓NARS-Python的exe界面可能会在终止后延时关闭
- ❌基于`julia`启动OpenJunars脚本`launch.jl`时,对「输出捕获」尚未有成功记录
- ❌目前对NARS-Python的「输出捕获」尚未有成功记录

## CLI测试:各CIN完成度评估

🕒最后更新时间:【2024-04-07 16:52:29】
Expand All @@ -79,6 +45,4 @@

## 参考

- [BabelNAR](https://github.com/ARCJ137442/BabelNAR.jl)
- [BabelNAR_Implements](https://github.com/ARCJ137442/BabelNAR_Implements.jl)
- [NAVM.rs](https://github.com/ARCJ137442/NAVM.rs)
- [BabelNAR.rs](https://github.com/ARCJ137442/BabelNAR.rs)
4 changes: 2 additions & 2 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@echo off

@REM 构建BabelNAR CLI(基于cargo)
cargo b -r --bin babelnar_cli
cargo b -r

@REM 重置dist文件夹
rm -rf dist
Expand All @@ -16,7 +16,7 @@ mkdir .\dist
xcopy /E /I .\config_public .\dist\nars_config

@REM 拷贝BabelNAR CLI
copy .\target\release\babelnar_cli.exe .\dist
copy .\target\release\babel_nar_cli.exe .\dist\babelnar_cli.exe

@REM 拷贝指定的可执行文件
xcopy /E /I .\executables\PyNARS .\dist\executables\PyNARS
Expand Down
2 changes: 1 addition & 1 deletion scripts/windows/release-launch-cxin_js.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
".\..\..\target\release\babelnar_cli.exe" -c ".\..\..\src\tests\cli\config\cin_cxin_js.hjson"
".\..\..\target\release\babel_nar_cli.exe" -c ".\..\..\config_public\cin_cxin_js.hjson"
2 changes: 1 addition & 1 deletion scripts/windows/release-launch-ona.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
".\..\..\target\release\babelnar_cli.exe" -c ".\..\..\src\tests\cli\config\cin_ona.hjson"
".\..\..\target\release\babel_nar_cli.exe" -c ".\..\..\src\tests\cli\config\cin_ona.hjson"
2 changes: 1 addition & 1 deletion scripts/windows/release-launch-opennars.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
".\..\..\target\release\babelnar_cli.exe" -c ".\..\..\src\tests\cli\config\cin_opennars.hjson"
".\..\..\target\release\babel_nar_cli.exe" -c ".\..\..\src\tests\cli\config\cin_opennars.hjson"
2 changes: 1 addition & 1 deletion scripts/windows/release-launch-pynars.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
".\..\..\target\release\babelnar_cli.exe" -c ".\..\..\src\tests\cli\config\cin_pynars.hjson"
".\..\..\target\release\babel_nar_cli.exe" -c ".\..\..\src\tests\cli\config\cin_pynars.hjson"
2 changes: 1 addition & 1 deletion scripts/windows/release-launch.cmd
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@echo off
".\..\..\target\release\babelnar_cli.exe"
".\..\..\target\release\babel_nar_cli.exe"
File renamed without changes.
Loading

0 comments on commit 2357f6f

Please sign in to comment.