Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shenmian/shell
A simple shell framework.
https://github.com/shenmian/shell
Last synced: about 1 month ago
JSON representation
A simple shell framework.
- Host: GitHub
- URL: https://github.com/shenmian/shell
- Owner: ShenMian
- License: mit
- Created: 2022-08-13T09:49:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-14T14:27:58.000Z (over 2 years ago)
- Last Synced: 2023-03-04T17:02:47.660Z (almost 2 years ago)
- Language: Shell
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shell
A simple shell framework.
## Modules
| Module | Description |
| ------ | ------------------- |
| io | 彩色输出. |
| oo | 基于类的面向对象. |
| system | 获取各类系统相关信息. |
| timer | 计时器. |
| color | 定义多种颜色. |## Usage
```sh
source "$( cd "${BASH_SOURCE[0]%/*}" && pwd )/path/to/import.sh"
import io system
```## 面向对象
```sh
# 声明类
class Timer
pub
fn Timer # 构造函数(可选)
fn -Timer # 析构函数(可选)
fn start
fn getSeconds
# ... 公有函数 ...
pri
# ... 私有函数 ...
var start_time
# ... 私有变量 ...# 定义成员函数
function Timer::start {
# 在成员函数中可以直接通过名称访问成员变量和成员函数
start_time="$(date +%s.%2N)"
}new Timer timer # 创建实例
timer.start # 调用成员函数
echo "Time: $(timer.getSeconds)sec" # 获取成员函数返回值
delete timer # 销毁实例
```