Package: ListBackupsArgsInterpreter
ListBackupsArgsInterpreter
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ListBackupsArgsInterpreter(DataManagerPresentationControl, DataManagerPresentation, UsageArgsInterpreter) |
|
|
|
|
|
||||||||||||||||||||
doRun(ApplicationArguments) |
|
|
|
|
|
||||||||||||||||||||
printUsage() |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
Coverage
1: /*
2: * *********************************************************************************************************************
3: *
4: * SolidBlue 3: Data safety
5: * http://tidalwave.it/projects/solidblue3
6: *
7: * Copyright (C) 2023 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/solidblue3j-src
23: * git clone https://github.com/tidalwave-it/solidblue3j-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.datamanager.application.nogui.args;
28:
29: import jakarta.annotation.Nonnull;
30: import java.util.Set;
31: import org.springframework.boot.ApplicationArguments;
32: import org.springframework.core.annotation.Order;
33: import org.springframework.stereotype.Component;
34: import it.tidalwave.datamanager.application.nogui.DataManagerPresentation;
35: import it.tidalwave.datamanager.application.nogui.DataManagerPresentationControl;
36: import lombok.extern.slf4j.Slf4j;
37: import static it.tidalwave.datamanager.application.nogui.DataManagerPresentationControl.BackupOptions.with;
38: import static it.tidalwave.datamanager.application.nogui.args.ArgumentsUtils.getStringOption;
39:
40: /***********************************************************************************************************************
41: *
42: * The command line args interpreter for the {@code list-files} command.
43: *
44: * @author Fabrizio Giudici
45: *
46: **********************************************************************************************************************/
47: @Component @Order(0) @Slf4j
48: public class ListBackupsArgsInterpreter extends ArgsInterpreterSupport implements UsageCapable
49: {
50: private static final String COMMAND = "list-backups";
51: private static final String O_LABEL = "label";
52: private static final String O_VOLUME_ID = "volume-id";
53: private static final String O_FILE_ID = "file-id";
54: private static final String O_FILES = "files";
55:
56: @Nonnull
57: private final DataManagerPresentationControl presentationControl;
58:
59: @Nonnull
60: private final DataManagerPresentation presentation;
61:
62: @Nonnull
63: private final UsageArgsInterpreter usageArgsInterpreter;
64:
65: /*******************************************************************************************************************
66: * {@inheritDoc}
67: ******************************************************************************************************************/
68: public ListBackupsArgsInterpreter (@Nonnull final DataManagerPresentationControl presentationControl,
69: @Nonnull final DataManagerPresentation presentation,
70: @Nonnull final UsageArgsInterpreter usageArgsInterpreter)
71: {
72: super(COMMAND, Set.of(O_LABEL, O_VOLUME_ID, O_FILE_ID, O_FILES), presentation);
73: this.presentationControl = presentationControl;
74: this.presentation = presentation;
75: this.usageArgsInterpreter = usageArgsInterpreter;
76: }
77:
78: /*******************************************************************************************************************
79: * {@inheritDoc}
80: ******************************************************************************************************************/
81: @Override
82: public void doRun (@Nonnull final ApplicationArguments args)
83: {
84: final var label = getStringOption(args, O_LABEL);
85: final var volumeId = getStringOption(args, O_VOLUME_ID);
86: final var renderFiles = args.containsOption(O_FILES);
87: final var fileId = getStringOption(args, O_FILE_ID);
88: usageArgsInterpreter.disableUsage();
89: presentationControl.renderBackups(with().label(label)
90: .volumeId(volumeId)
91: .fileId(fileId)
92: .renderFiles(renderFiles));
93: }
94:
95: /*******************************************************************************************************************
96: * {@inheritDoc}
97: ******************************************************************************************************************/
98: @Override
99: public void printUsage()
100: {
101: presentation.output("""
102: solidblue3 %1$s [--%2$s=<label>] [--%3$s=<volume-id>] [--%4$s=<file-id>] [--%5$s]
103: list backups on the console
104: --%2$s=<label> the label of the backup
105: --%3$s=<volume-id> the volume id of the backup
106: --%4$s=<file-id> the id of a file in the backup
107: --%5$s also render files
108: """.formatted(COMMAND, O_LABEL, O_VOLUME_ID, O_FILE_ID, O_FILES));
109: }
110: }