@author nano
| 39 | * @author nano |
| 40 | */ |
| 41 | @ShellComponent |
| 42 | @Order(1) |
| 43 | public class BucketCommands |
| 44 | extends Commands { |
| 45 | |
| 46 | public static class Args { |
| 47 | @Parameter(names = {"--type", |
| 48 | "-t"}, order = 0, description = "【不同类型的云厂家,如阿里、腾讯、亚马逊】Different kind of Cloud,such as OSS(aliyun)\\COS(\\Tencent)\\S3(Amazon)", required = true) |
| 49 | private String type = ""; |
| 50 | |
| 51 | @Parameter(names = {"--endpoint", |
| 52 | "-e"}, order = 1, description = "【endpoint地址,支持私有云和内部网络】endpoint address,support http and https", required = true) |
| 53 | private String endpoint = ""; |
| 54 | |
| 55 | @Parameter(names = {"--bucketname", |
| 56 | "-b"}, order = 2, description = "【bucket名称】bucketname, you known", required = true) |
| 57 | private String bucketname = ""; |
| 58 | |
| 59 | @Parameter(names = {"--path", "-p"}, order = 3, description = "【bucket下的多级目录】path just like dir", required = false) |
| 60 | private String path = "/"; |
| 61 | |
| 62 | @Parameter(names = {"--accessKeyId", "-ak"}, order = 4, description = "accessKeyId", required = true, password = true) |
| 63 | private String accessKeyId = ""; |
| 64 | |
| 65 | @Parameter(names = {"--accessKeySecret", |
| 66 | "-sk"}, order = 5, description = "accessKeySecret", required = true, password = true) |
| 67 | private String accessKeySecret = ""; |
| 68 | |
| 69 | // @Parameter( names = { "--ststoken", "-t" }, order = 6, description = "token", required = false, password = true ) |
| 70 | // private String token = ""; |
| 71 | |
| 72 | @Parameter(names = {"--help", "-h"}, help = true, order = 8) |
| 73 | private boolean help; |
| 74 | |
| 75 | @Parameter(names = {"--version", |
| 76 | "-v"}, description = "【显示版本信息】Display version information", help = true, order = 9) |
| 77 | private boolean v; |
| 78 | |
| 79 | } |
| 80 | |
| 81 | @ShellMethod("【远端对象存储配置】Config bucket connect and list active session manipulation and interaction... \nYou should have read permission to the bucket. \nUse config --help for more information") |
| 82 | public String config(@ShellOption(optOut = true) @Valid Args args) { |
| 83 | |
| 84 | setBucketname(args.bucketname); |
| 85 | setEndpoint(args.endpoint); |
| 86 | setAccessKeyId(args.accessKeyId); |
| 87 | setAccessKeySecret(args.accessKeySecret); |
| 88 | setPath(args.path); |
| 89 | setType(args.type.toUpperCase()); |
| 90 | JCommander jCommander = new JCommander(args); |
| 91 | |
| 92 | if (args.help) { |
| 93 | jCommander.setProgramName("config"); |
| 94 | jCommander.usage(); |
| 95 | return ""; |
| 96 | } |
| 97 | if (args.v) { |
| 98 | return "Version : 2.0 (2020-10-06 21:44:14) On " + System.getProperty("os.name"); |
nothing calls this directly
no outgoing calls
no test coverage detected