mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-28 17:30:40 +00:00
Merge pull request #93 from ThomasFok/fix/lock_del_cmd_help_msg
acx - help messages of delete and lock command are wrong
This commit is contained in:
commit
801cf68745
@ -28,25 +28,23 @@ import com.webcodepro.applecommander.util.filestreamer.FileStreamer;
|
|||||||
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
||||||
import com.webcodepro.applecommander.util.filestreamer.TypeOfFile;
|
import com.webcodepro.applecommander.util.filestreamer.TypeOfFile;
|
||||||
|
|
||||||
import picocli.CommandLine.Parameters;
|
|
||||||
|
|
||||||
public abstract class ReadWriteDiskCommandWithGlobOptions extends ReadWriteDiskCommandOptions {
|
public abstract class ReadWriteDiskCommandWithGlobOptions extends ReadWriteDiskCommandOptions {
|
||||||
private static Logger LOG = Logger.getLogger(ReadWriteDiskCommandWithGlobOptions.class.getName());
|
private static Logger LOG = Logger.getLogger(ReadWriteDiskCommandWithGlobOptions.class.getName());
|
||||||
|
|
||||||
@Parameters(arity = "1..*", description = "File glob(s) to unlock (default = '*') - be cautious of quoting!")
|
//Subclasses must declare globs data member and implement getGlobs() method
|
||||||
private List<String> globs = Arrays.asList("*");
|
protected abstract List<String> getGlobs();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int handleCommand() throws Exception {
|
public int handleCommand() throws Exception {
|
||||||
List<FileTuple> files = FileStreamer.forDisk(disk)
|
List<FileTuple> files = FileStreamer.forDisk(disk)
|
||||||
.ignoreErrors(true)
|
.ignoreErrors(true)
|
||||||
.includeTypeOfFile(TypeOfFile.FILE)
|
.includeTypeOfFile(TypeOfFile.FILE)
|
||||||
.matchGlobs(globs)
|
.matchGlobs(this.getGlobs())
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (files.isEmpty()) {
|
if (files.isEmpty()) {
|
||||||
LOG.warning(() -> String.format("No matches found for %s.", String.join(",", globs)));
|
LOG.warning(() -> String.format("No matches found for %s.", String.join(",", this.getGlobs())));
|
||||||
} else {
|
} else {
|
||||||
files.forEach(this::fileHandler);
|
files.forEach(this::fileHandler);
|
||||||
}
|
}
|
||||||
|
@ -20,18 +20,27 @@
|
|||||||
package io.github.applecommander.acx.command;
|
package io.github.applecommander.acx.command;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
||||||
|
|
||||||
import io.github.applecommander.acx.base.ReadWriteDiskCommandWithGlobOptions;
|
import io.github.applecommander.acx.base.ReadWriteDiskCommandWithGlobOptions;
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
import picocli.CommandLine.Option;
|
import picocli.CommandLine.Option;
|
||||||
|
import picocli.CommandLine.Parameters;
|
||||||
|
|
||||||
@Command(name = "delete", description = "Delete file(s) from a disk image.",
|
@Command(name = "delete", description = "Delete file(s) from a disk image.",
|
||||||
aliases = { "del", "rm" })
|
aliases = { "del", "rm" })
|
||||||
public class DeleteCommand extends ReadWriteDiskCommandWithGlobOptions {
|
public class DeleteCommand extends ReadWriteDiskCommandWithGlobOptions {
|
||||||
private static Logger LOG = Logger.getLogger(DeleteCommand.class.getName());
|
private static Logger LOG = Logger.getLogger(DeleteCommand.class.getName());
|
||||||
|
|
||||||
|
@Parameters(arity = "1..*", description = "File glob(s) to delete (default = '*') - be cautious of quoting!")
|
||||||
|
private List<String> globs = Arrays.asList("*");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> getGlobs(){return globs;}
|
||||||
|
|
||||||
@Option(names = { "-f", "--force" }, description = "Force delete locked files.")
|
@Option(names = { "-f", "--force" }, description = "Force delete locked files.")
|
||||||
private boolean forceFlag;
|
private boolean forceFlag;
|
||||||
|
|
||||||
|
@ -20,16 +20,25 @@
|
|||||||
package io.github.applecommander.acx.command;
|
package io.github.applecommander.acx.command;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
||||||
|
|
||||||
import io.github.applecommander.acx.base.ReadWriteDiskCommandWithGlobOptions;
|
import io.github.applecommander.acx.base.ReadWriteDiskCommandWithGlobOptions;
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
|
import picocli.CommandLine.Parameters;
|
||||||
|
|
||||||
@Command(name = "lock", description = "Lock file(s) on a disk image.")
|
@Command(name = "lock", description = "Lock file(s) on a disk image.")
|
||||||
public class LockCommand extends ReadWriteDiskCommandWithGlobOptions {
|
public class LockCommand extends ReadWriteDiskCommandWithGlobOptions {
|
||||||
private static Logger LOG = Logger.getLogger(LockCommand.class.getName());
|
private static Logger LOG = Logger.getLogger(LockCommand.class.getName());
|
||||||
|
|
||||||
|
@Parameters(arity = "1..*", description = "File glob(s) to lock (default = '*') - be cautious of quoting!")
|
||||||
|
private List<String> globs = Arrays.asList("*");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> getGlobs(){return globs;}
|
||||||
|
|
||||||
public void fileHandler(FileTuple tuple) {
|
public void fileHandler(FileTuple tuple) {
|
||||||
tuple.fileEntry.setLocked(true);
|
tuple.fileEntry.setLocked(true);
|
||||||
LOG.info(() -> String.format("File '%s' locked.", tuple.fileEntry.getFilename()));
|
LOG.info(() -> String.format("File '%s' locked.", tuple.fileEntry.getFilename()));
|
||||||
|
@ -20,17 +20,26 @@
|
|||||||
package io.github.applecommander.acx.command;
|
package io.github.applecommander.acx.command;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
import com.webcodepro.applecommander.util.filestreamer.FileTuple;
|
||||||
|
|
||||||
import io.github.applecommander.acx.base.ReadWriteDiskCommandWithGlobOptions;
|
import io.github.applecommander.acx.base.ReadWriteDiskCommandWithGlobOptions;
|
||||||
import picocli.CommandLine.Command;
|
import picocli.CommandLine.Command;
|
||||||
|
import picocli.CommandLine.Parameters;
|
||||||
|
|
||||||
@Command(name = "unlock", description = "Unlock file(s) on a disk image.")
|
@Command(name = "unlock", description = "Unlock file(s) on a disk image.")
|
||||||
public class UnlockCommand extends ReadWriteDiskCommandWithGlobOptions {
|
public class UnlockCommand extends ReadWriteDiskCommandWithGlobOptions {
|
||||||
private static Logger LOG = Logger.getLogger(UnlockCommand.class.getName());
|
private static Logger LOG = Logger.getLogger(UnlockCommand.class.getName());
|
||||||
|
|
||||||
public void fileHandler(FileTuple tuple) {
|
@Parameters(arity = "1..*", description = "File glob(s) to unlock (default = '*') - be cautious of quoting!")
|
||||||
|
private List<String> globs = Arrays.asList("*");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> getGlobs(){return globs;}
|
||||||
|
|
||||||
|
public void fileHandler(FileTuple tuple) {
|
||||||
tuple.fileEntry.setLocked(false);
|
tuple.fileEntry.setLocked(false);
|
||||||
LOG.info(() -> String.format("File '%s' unlocked.", tuple.fileEntry.getFilename()));
|
LOG.info(() -> String.format("File '%s' unlocked.", tuple.fileEntry.getFilename()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user