return 0;
}
@Override
public LsOperationOptions parseOptions(String[] operationArgs) throws Exception {
LsOperationOptions operationOptions = new LsOperationOptions();
OptionParser parser = new OptionParser();
parser.allowsUnrecognizedOptions();
OptionSpec<String> optionDateStr = parser.acceptsAll(asList("D", "date")).withRequiredArg();
OptionSpec<Void> optionRecursive = parser.acceptsAll(asList("r", "recursive"));
OptionSpec<String> optionFileTypes = parser.acceptsAll(asList("t", "types")).withRequiredArg();
OptionSpec<Void> optionLongChecksums = parser.acceptsAll(asList("f", "full-checksums"));
OptionSpec<Void> optionWithVersions = parser.acceptsAll(asList("V", "versions"));
OptionSpec<Void> optionGroupedVersions = parser.acceptsAll(asList("g", "group"));
OptionSet options = parser.parse(operationArgs);
// --date=..
if (options.has(optionDateStr)) {
Date logViewDate = parseDateOption(options.valueOf(optionDateStr));
operationOptions.setDate(logViewDate);
}
// --recursive
operationOptions.setRecursive(options.has(optionRecursive));
// --types=[tds]
if (options.has(optionFileTypes)) {
String fileTypesStr = options.valueOf(optionFileTypes).toLowerCase();
HashSet<FileType> fileTypes = new HashSet<>();
if (fileTypesStr.contains("f")) {
fileTypes.add(FileType.FILE);
}
if (fileTypesStr.contains("d")) {
fileTypes.add(FileType.FOLDER);
}
if (fileTypesStr.contains("s")) {
fileTypes.add(FileType.SYMLINK);
}
operationOptions.setFileTypes(fileTypes);
}
// --versions
fetchHistories = options.has(optionWithVersions);
operationOptions.setFetchHistories(fetchHistories);
// --long-checksums (display option)
checksumLength = (options.has(optionLongChecksums)) ? CHECKSUM_LENGTH_LONG : CHECKSUM_LENGTH_SHORT;
// --group (display option)
groupedVersions = options.has(optionGroupedVersions);
// <path-expr>
List<?> nonOptionArgs = options.nonOptionArguments();
if (nonOptionArgs.size() > 0) {
operationOptions.setPathExpression(nonOptionArgs.get(0).toString());
}
return operationOptions;
}