# ola **Repository Path**: bzhaoop/ola ## Basic Information - **Project Name**: ola - **Description**: A fancy shell command-line tools framework - **Primary Language**: Unknown - **License**: MulanPSL-2.0 - **Default Branch**: develop - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 4 - **Created**: 2021-08-03 - **Last Updated**: 2021-08-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README - [1. 简介](#1-简介) - [2. 目录](#2-目录) - [3. 使用](#3-使用) - [3.1. 开发](#31-开发) - [3.2. 执行](#32-执行) - [3.3. 环境](#33-环境) - [3.4. 配置](#34-配置) - [4. 结语](#4-结语) # 1. 简介 ola(哦啦),对,不是euler(欧拉) -_- ola实际上是我为openEuler写的一个shell脚本框架。 ola可以让你体会到shell脚本的优雅,当然,你可以不相信,反正我着迷了…… ola采用了面向过程的编程思想,除了简单的原因,还因为我曾经是一个 C-Coder …… # 2. 目录 |一级目录|二级目录|说明| |:---|:---|:---| |ola.sh||命令入口| |src|apps|应用(命令)脚本| ||libs|库脚本,基于标准命令实现| ||utils|通用脚本,框架的核心| |test||测试脚本| 备注:utils和libs中的脚本都是通用的,可以广泛的用在别的项目中。 # 3. 使用 ## 3.1. 开发 如何开发一个功能?以helloworld.sh为例,如下: ```shell method_def helloworld usage_helloworld() { echo "helloworld (hello): Hello to the world" } alias_def helloworld hello do_helloworld() { echo "hello world" } ``` 1. 一个功能必须定义两个函数:do_helloworld,usage_helloworld 备注: * do_xxx和usage_xxx后面的名字必须一致 * usage_xxx第一行是功能的简述,通过':'分割 2. 一个功能通过method定义后才生效:method_def helloworld 备注: * method定义的方法,最终在ola中以子命令的形式存在 3. 一个功能别名通过alias定义:alias_def helloworld hello 备注: * alias定义的别名,最终在ola中也以子命令的形式存在 * ailas可以定义多个别名,比如:alias_def helloworld hello hw ## 3.2. 执行 通过执行ola.sh脚本来执行不同的功能。 1. 查看所有帮助信息 ``` bash ola.sh [-h|--help] ``` 2. 查看命令帮助信息 ``` bash ola.sh h helloworld bash ola.sh h hello ``` 3. 执行命令 ``` bash ola.sh helloworld bash ola.sh hello ``` ## 3.3. 环境 功能中会使用一些非系统内嵌的命令,这些命令可能需要单独进行安装,通过下面命令可以检测当前系统中是否存在用到的相关命令: ``` bash ola.sh checkenv bash ola.sh ce ``` ## 3.4. 配置 有些命令需要先配置信息,ola的配置模板文件在config/ola.conf中,通过变量CONFIG_FILE指定配置文件。 ola提供了两个命令用来管理配置文件:init,set ``` bash ola.sh init bash ola.sh set ``` init:初始化配置文件 set:设置/编辑配置文件 # 4. 结语 更多功能请自行解锁!