5 Star 19 Fork 4

iDev_周晶 / lego

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README.md 4.62 KB
一键复制 编辑 原始数据 按行查看 历史
周晶 提交于 2019-10-28 12:36 . update docs

Lego / 乐高

   ██▓    ▓█████   ▄████  ▒█████  
  ▓██▒    ▓█   ▀  ██▒ ▀█▒▒██▒  ██▒
  ▒██░    ▒███   ▒██░▄▄▄░▒██░  ██▒
  ▒██░    ▒▓█  ▄ ░▓█  ██▓▒██   ██░
  ░██████▒░▒████▒░▒▓███▀▒░ ████▓▒░
  ░ ▒░▓  ░░░ ▒░ ░ ░▒   ▒ ░ ▒░▒░▒░ 
  ░ ░ ▒  ░ ░ ░  ░  ░   ░   ░ ▒ ▒░ 
    ░ ░      ░   ░ ░   ░ ░ ░ ░ ▒  
      ░  ░   ░  ░      ░     ░ ░  

this is the lego version for runX, its soul is came from the summarize about runX, k8s-start, wtool(a inner tools set for weibo staffs). It is designed to combine various system deployment and management functions like building blocks, effectively reuse code, improve work efficiency and free hands.

quick start

Lego can be started quickly with a few commands.

installation

Simply run the following command to install the Lego.

sh -c "$(curl -sSL https://raw.githubusercontent.com/idevz/lego/master/get.sh)"
# sh -c "$(curl -H 'Cache-Control: no-cache' \
#     -sSL 'https://raw.githubusercontent.com/idevz/lego/master/get.sh')"

examples of other commands

# Add the third-party module "idevz"
o lego add idevz
# Run the relevant commands of the module "idevz"
o idevz your_function

auto-complete

Append the following command to the corresponding shell.rc file to enable automatic completion of the command.

source $YOUR_LEGO_ROOT/lego/ac/auto-complete

In the case of ZSH, simply append the above command at the end of the ~/.zshrc file, and then execute source ~/.zshrc to make the append take effect to complete automatic completion.

# Note that replace the $YOUR_LEGO_ROOT with your own Lego installation root
# Run the `o l_status` command to get the current LEGO_ROOT path
echo 'source $YOUR_LEGO_ROOT/lego/ac/auto-complete' >> ~/.zshrc

Main functions and ideas

  • Quickly set up the experimental environment, deploy PVM(Parallels Virtual Machines), and manage PVM via the PRLCTL tool.
  • The modules are divided into built-in and third-party modules. The modules are organized in the same way, and the functions are provided by scripts in the legoes directory under each module
  • By default, the project's common libraries and functions are loaded sequentially according to the configuration and sequence in the lego/legoes/export file
  • There are two types of functions, command and module functions. Although they can theoretically be called directly, they are named differently and functionally positioned differently.
  • Module function is the encapsulation of various scattered functions in each module. "Command::module-name::function-name", For example, "pvm::deploy::init_etc" means the function init_etc in the deploy module under the pvm command In principle, direct calls are avoided, but if they must be, the corresponding command is o pvm deploy::init_etc.
  • Command function is the carrier of various command operation, which is the encapsulation and combination of "module function". Lego's idea is mainly reflected in this part. The name is called "command name", but it is important to note that command functions can only be defined in "helpers.sh" files for each module, File names must be "helpers.sh", such as the "start" function in pvm/legoes/helpers.sh, which corresponds to the command o pvm start
  • With the exception of the global module in the lego directory, all the other functions use the command to backload the corresponding file, and it can also dock with the automatic completion (the automatic completion has not been implemented yet).

Norms and conventions

  • The help information for all functions is written on the previous line of the corresponding function definition. Lego will parse the shell file to get all the available functions and their corresponding help information (help information should not be too long, just briefly explain the main points).

TODO

  • Optimize auto completion (For example, complete the module first, and then complete the relevant commands behind the module)
  • update,remove modules
  • -h Commands support explicit help information by module name
Shell
1
https://gitee.com/_k/lego.git
git@gitee.com:_k/lego.git
_k
lego
lego
master

搜索帮助