Skip to content

Commit

Permalink
修改命令参数,文件重构
Browse files Browse the repository at this point in the history
  • Loading branch information
赵栩彬 committed Jul 30, 2019
1 parent aca835e commit 3f39eda
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ Java version must be greater than 1.8
-d | --download <url> [文件名] url链接下载文件
```

#### 其它
```cmd
-h | --help 命令帮助
-v | --version 版本
```



16 changes: 9 additions & 7 deletions src/main/java/fyan/FyanApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
package fyan;

import fyan.base.Base;
import fyan.cmd_down.Down;
import fyan.cmd_secr.*;
import fyan.cmd_file.Append;
import fyan.cmd_file.Create;
import fyan.cmd_file.Replace;
import fyan.cmd_file.Substr;
import fyan.cmd_sys.Help;
import fyan.cmd_sys.Version;

import static fyan.base.Base.primList;

Expand All @@ -46,23 +48,23 @@ public class FyanApplication {
primList.put("-r", Replace.class);
primList.put("--replace", Replace.class);
primList.put("-a", Append.class);
primList.put("-append", Append.class);
primList.put("--append", Append.class);
primList.put("-f", Fingerprint.class);
primList.put("--finger", Fingerprint.class);
primList.put("-finger", Fingerprint.class);
primList.put("-d", Down.class);
primList.put("-down", Down.class);
primList.put("-v", Version.class);
primList.put("--version", Version.class);
}

public static String LOCAL_PATH;
public static String REGEX;

public static void main(String[] args) {

for (String s : args)
System.out.println(s);

System.out.println(args.length);
LOCAL_PATH = args[0] + "\\";
String[] command;
if (args.length>=2&&"grep".equals(args[args.length - 2])) {
if (args.length >= 2 && "grep".equals(args[args.length - 2])) {
REGEX = args[args.length - 1];
command = new String[args.length - 3];
} else
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/fyan/base/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ public class Base {

public static void handle(String[] args) {

System.out.println(args.length);
try {
Class filterClass;
if (args.length == 0)
filterClass = Version.class;
else filterClass = primList.get(args[0]);
CommandBase filterBase = (CommandBase) filterClass.newInstance();
int resCode = filterBase.resInfo(args);
System.out.print("\n"+(resCode == 0 ? "success" : (resCode == -1 ? "fault" : "warning")));
} catch (Exception e) {
System.out.print("\t命令或参数错误, -help 查看命令详细");
} finally {
Expand Down
35 changes: 14 additions & 21 deletions src/main/java/fyan/cmd_sys/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,25 @@
public class Help implements CommandBase {

public int resInfo(String[] args) {
System.out.print( "\t-h 或 -help \n" +
"\t\t显示命令使用帮助\n" +
System.out.print( "\t -a | --append [pre/suf] <constName> 修改文件前缀或后缀\n" +
"\t \n" +
"\t -c | --create [total] <constName> [进值+步长+位数] <a/d> 创建及命名文件夹\n" +
"\t \n" +
"\t -c | --create -l [dictionaryName...] 创建文件夹以常量的方式\n" +
"\t \n" +
"\t -r | --replace [regex] [replacement] 正则修改文件名\n" +
"\t \n" +
"\t -s | --Substr <beginIndex> [endIndex] 截取文件名\n" +
"\n" +
"\t| grep <正则表达式>\n" +
"\t\t以下所有命令尾部都可加上此命令做正则筛选\n" +
"\t -f | --finger <MD5|SHA-1|SHA-256|SHA-384|SHA-512> <fileName> 以指定算法计算文件摘要\n" +
"\n" +
"\t| limit <个数> \n" +
"\t\t以下所有命令尾部都可加上此命令做指定个数选择\n" +
"\t -f | --finger -c|--compared <MD5|SHA-1|SHA-256|SHA-384|SHA-512> <fileName> <fingerPrint> 对比摘要,文件防篡改\n" +
"\n" +
"\t-c or -create <文件夹个数> [命名规则](默认以数字从0开始) \n" +
"\t\t批量创建文件夹。命名规则:{常量}[变量][进值][位数]\n" +
"\t -d | --download <url> [文件名] url链接下载文件\n" +
"\n" +
"\t-m or -modify [pre/suf] [命名规则](默认以数字从0开始) \n" +
"\t\t批量修改文件名前缀或后缀。\n" +
"\t -h | --help 命令帮助\n" +
"\n" +
"\t-s or -substring <beginIndex> [endIndex] \n" +
"\t\t切割文件名,删掉指定文件名字符索引段。endIndex缺省文件名长度\n" +
"\n" +
"\t-r or -replace [regex] [replacement] \n" +
"\t\t切割文件名,删掉指定文件名字符索引段。endIndex缺省文件名长度\n" +
"\n" +
"\t-lc or -lower [regex] [replacement] \n" +
"\t\t文件名转小写\n" +
"\t\t\n" +
"\t-uc or -up [regex] [replacement] \n" +
"\t\t文件名转大写");
"\t -v | --version 版本");
return 0;
}
}
2 changes: 1 addition & 1 deletion src/main/java/fyan/cmd_sys/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public int resInfo(String[] args) {

System.out.print("Welcome to the folder processing tool from yanyan.site\n" +
"Version 1.1.0\n" +
"Java version must be greater than 1.8");
"Java version must be greater than 1.8\n");
return 0;
}
}

0 comments on commit 3f39eda

Please sign in to comment.