Skip to content

Commit

Permalink
Merge branch 'release/refactor_cli_opt'
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuSugar committed Jul 20, 2021
2 parents f76fea3 + bb1b8ab commit 69e14a5
Show file tree
Hide file tree
Showing 23 changed files with 623 additions and 98 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Randomly generated data tool
### web界面
![主界面](https://cdn.jsdelivr.net/gh/mikusugar/PictureBed@master/uPic/2021/06/2W0rwN.png)
### CLI界面
![CLI](docs/assets/cli启动.gif)
![CLI](docs/assets/cli_new.gif)
## 程序文档
[SugarRandom 官网](https://mikusugar.me/SugarRandom/)

Expand Down
Binary file added docs/assets/alias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/cli_new.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/mkarr.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/mkobj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/rm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/touch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/命令展示1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions docs/usage_cli/quick_cli_new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# CLI 新版命令

> 老版的命令暂时和新版的命令共存,新版的命令风格模仿unix 文件的命令。文件系统是一颗树,json也是一颗树,所以这套命令应该比较容易上手。
## 命令概述

+ **cd**: 进入到某个节点

+ **ll**: 展示结构
+ **pwd**: 当前节点路径
+ **alias**: 别名,仅针对随机类型名,会覆盖,优先级大于随机类型名

+ **mkarr**: 添加一个数组,input 参考 [show-rtype 随机数组长度]

+ **mkobj**: 添加一个object

+ **rm**: 删除

+ **touch**: 添加字段

## 详细说明

### cd、ll、pwd

> 这个大家应该很熟悉了,支持绝对路径和相对路径
![命令展示1](../assets/命令展示1.gif)

### mkarr

建立一个数组 参数是数组名和数组长度配置。

```shell
🍭 root :>help mkarr
NAME
mkarr - 添加一个数组,input 参考 [show-rtype 随机数组长度]

SYNOPSYS
mkarr [--name] string [--input] string

OPTIONS
--name string

[Mandatory]

--input string

[Mandatory]
```

例如下面演示了在info下建立一个数组

![mkarr](../assets/mkarr.gif)

### mkobj

建立一个对象,参数只有一个对象名字。

![image-20210720180538135](../assets/mkobj.png)

### touch

和老版的 add 命令类似,与add相比少了一个father,因为father就是当前“目录”。

![image-20210720180751549](../assets/touch.png)

### rm

支持绝对路径和相对路径

![image-20210720181042793](../assets/rm.png)

### alias

> 考虑到随机类型过于长,所以支持别名。(目前还没有想好怎么优化
![image-20210720181258613](../assets/alias.png)

## 其它

其它的命令如show系列,请看[老版文档](quick_cli.md),目前命令是共存的。

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ nav:
- 配置: usage_web/config.md
- CLI使用:
- 快速使用: usage_cli/quick_cli.md
- 新版命令: usage_cli/quick_cli_new.md
- 开发:
- 简介: develop/index.md
- 新的随机类型: develop/newtype.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void onComponentEvent(ClickEvent<Button> buttonClickEvent) {
.get(randomType.getValue())
.createRandomCoreService(randomInfo.getValue()))
.desc(randomServiceMap.get(randomType.getValue()).helpText())
.father(map.get(fieldFather.getValue()))
.build();
map.get(fieldFather.getValue()).getNexts().add(node);
map.put(node.getName(), node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import org.jline.utils.AttributedString;
import org.springframework.shell.jline.PromptProvider;

@SpringBootApplication
@ComponentScan({"me.mikusugar.random.core", "me.mikusugar.sugar.random.cli"})
@EnableJpaRepositories("me.mikusugar.random.core")
Expand All @@ -17,10 +13,4 @@ public class App {
public static void main(String[] args) {
SpringApplication.run(App.class,args);
}

@Bean
public PromptProvider myPromptProvider() {
return () -> new AttributedString("🍭:>");
}

}
Loading

0 comments on commit 69e14a5

Please sign in to comment.