/** * * @author jdenise@redhat.com */ public abstract class AbstractFPProvisioningCommand extends AbstractStateCommand { @Argument(completer = FPLocationCompleter.class, required = true, description = HelpDescriptions.FP_LOCATION) protected String fpl; @Override protected void runCommand(PmCommandInvocation invoc, State session) throws IOException, ProvisioningException, CommandExecutionException { FeaturePackLocation fpl = invoc.getPmSession().getResolvedLocation(null, this.fpl); runCommand(invoc, session, fpl); } protected abstract void runCommand(PmCommandInvocation invoc, State session, FeaturePackLocation fpl) throws IOException, ProvisioningException, CommandExecutionException; public String getName() { return fpl; } }
.shortName('\u0000') .name("") .description(arg.description()) .required(arg.required()) .valueSeparator(' ') .askIfNotSet(arg.askIfNotSet()) .addAllDefaultValues(arg.defaultValue()) .type(field.getType()) .fieldName(field.getName()) .optionType(optionType) .converter(arg.converter()) .completer(arg.completer()) .validator(arg.validator()) .activator(arg.activator()) .renderer(arg.renderer()) .parser(arg.parser()) .overrideRequired(arg.overrideRequired()) .build() );
@Argument(required = true, description = HelpDescriptions.PACKAGE_NAME, completer = PackageCompleter.class) private String pkg;
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "enable-offline", description = HelpDescriptions.MVN_ENABLE_OFFLINE) public class MavenEnableOffline extends PmSessionCommand { @Argument(completer = BooleanCompleter.class, description = HelpDescriptions.BOOLEAN_OPT, required = true) private String offline; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { try { session.getPmSession().getPmConfiguration().getMavenConfig().enableOffline(BooleanCompleter.validateValue(offline)); } catch (XMLStreamException | IOException ex) { throw new CommandExecutionException(ex.getLocalizedMessage()); } } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "enable-release", description = HelpDescriptions.MVN_ENABLE_RELEASE) public class MavenEnableRelease extends PmSessionCommand { @Argument(completer = BooleanCompleter.class, description = HelpDescriptions.BOOLEAN_OPT, required = true) private String enable; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { try { session.getPmSession().getPmConfiguration().getMavenConfig(). enableRelease(BooleanCompleter.validateValue(enable)); } catch (XMLStreamException | IOException ex) { throw new CommandExecutionException(ex.getLocalizedMessage()); } } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "enable-snapshot", description = HelpDescriptions.MVN_ENABLE_SNAPSHOT) public class MavenEnableSnapshot extends PmSessionCommand { @Argument(completer = BooleanCompleter.class, description = HelpDescriptions.BOOLEAN_OPT, required = true) private String enable; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { try { session.getPmSession().getPmConfiguration().getMavenConfig(). enableSnapshot(BooleanCompleter.validateValue(enable)); } catch (XMLStreamException | IOException ex) { throw new CommandExecutionException(ex.getLocalizedMessage()); } } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "set-snapshot-update-policy", description = HelpDescriptions.MVN_SET_DEFAULT_SNAPSHOT_POLICY) public class MavenSetSnapshotPolicy extends PmSessionCommand { @Argument(completer = MavenAddRepository.UpdatePolicyCompleter.class, description = HelpDescriptions.MVN_UPDATE_POLICY, required = true) private String policy; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { try { session.getPmSession().getPmConfiguration().getMavenConfig().setDefaultSnapshotPolicy(policy); } catch (ProvisioningException | XMLStreamException | IOException ex) { throw new CommandExecutionException(ex.getLocalizedMessage()); } } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "set-release-update-policy", description = HelpDescriptions.MVN_SET_DEFAULT_RELEASE_POLICY) public class MavenSetReleasePolicy extends PmSessionCommand { @Argument(completer = MavenAddRepository.UpdatePolicyCompleter.class, description = HelpDescriptions.MVN_UPDATE_POLICY, required = true) private String policy; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { try { session.getPmSession().getPmConfiguration().getMavenConfig().setDefaultReleasePolicy(policy); } catch (ProvisioningException | XMLStreamException | IOException ex) { throw new CommandExecutionException(ex.getLocalizedMessage()); } } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "set-local-repository", description = HelpDescriptions.MVN_SET_LOCAL_PATH) public class MavenSetLocalRepository extends PmSessionCommand { @Argument(description = HelpDescriptions.MVN_LOCAL_REPO_PATH, required = true) private File path; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { Path p = path.toPath(); try { if (!Files.exists(p)) { throw new CommandExecutionException("Local repository directory " + p + " doesn't exist."); } session.getPmSession().getPmConfiguration().getMavenConfig().setLocalRepository(p); } catch (XMLStreamException | IOException ex) { throw new CommandExecutionException(session.getPmSession(), CliErrors.setLocalRepositoryFailed(), ex); } } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "set-settings-file", description = HelpDescriptions.MVN_SET_SETTINGS_PATH) public class MavenSetSettings extends PmSessionCommand { @Argument(description = HelpDescriptions.MVN_SETTINGS_PATH, required = true) private File path; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { Path p = path.toPath(); try { if (!Files.exists(p)) { throw new CommandExecutionException("settings file " + p + " doesn't exist."); } session.getPmSession().getPmConfiguration().getMavenConfig().setSettings(p); } catch (XMLStreamException | IOException ex) { throw new CommandExecutionException(session.getPmSession(), CliErrors.setSettingsFailed(), ex); } } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "set-history-limit", description = HelpDescriptions.SET_HISTORY_LIMIT) public class SetHistoryLimitCommand extends AbstractInstallationCommand { // We can't rely on Integer injection due to AESH-479. @Argument(required = true, description = HelpDescriptions.HISTORY_LIMIT) private String limit; @Override protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException { try { int s; try { s = Integer.parseInt(limit); } catch (NumberFormatException ex) { throw new CommandExecutionException(CliErrors.invalidHistoryLimit(limit)); } getManager(invoc.getPmSession()).setStateHistoryLimit(s); } catch (ProvisioningException ex) { throw new CommandExecutionException(invoc.getPmSession(), CliErrors.setHistoryLimitFailed(), ex); } } }
@CommandDefinition(name = "ls", description = HelpDescriptions.LS) public class StateLsCommand extends PmSessionCommand { @Argument(completer = StateFullPathCompleter.class, description = HelpDescriptions.FP_PATH) private String path; @Override protected void runCommand(PmCommandInvocation session) throws CommandExecutionException { if (path == null || path.isEmpty()) { path = session.getPmSession().getCurrentPath(); } FeatureContainer container = session.getPmSession().getContainer(); if (!path.startsWith("" + PathParser.PATH_SEPARATOR)) { path = session.getPmSession().getCurrentPath() + path; } try { StateInfoUtil.printContentPath(session, container, path); } catch (Exception ex) { throw new CommandExecutionException(session.getPmSession(), CliErrors.displayContentFailed(), ex); } } @Override public CommandDomain getDomain() { return CommandDomain.EDITING; } }
/** * * @author jdenise@redhat.com */ @CommandDefinition(name = "edit", description = HelpDescriptions.EDIT_STATE) public class StateEditCommand extends PmSessionCommand { @Argument(required = false, description = HelpDescriptions.EDIT_STATE_ARG) protected File dir; @Override protected void runCommand(PmCommandInvocation invoc) throws CommandExecutionException { State state; try { state = new State(invoc.getPmSession(), getInstallationHome(invoc.getConfiguration().getAeshContext())); } catch (ProvisioningException | IOException ex) { throw new CommandExecutionException(invoc.getPmSession(), CliErrors.readContentFailed(), ex); } invoc.getPmSession().setState(state); invoc.setPrompt(invoc.getPmSession().buildPrompt(state.getPath())); invoc.println(WELCOME_STATE_MSG); } protected Path getInstallationHome(AeshContext context) { return dir == null ? PmSession.getWorkDir(context) : dir.toPath(); } }
@Argument(required = true) private File file;
@Argument(description = HelpDescriptions.MVN_REPO_NAME, required = true, completer = RepositoriesCompleter.class) private String name;
@Argument(required = true) private File file;
@Argument(completer = ProvisionedFPCompleter.class, description = HelpDescriptions.FP_TO_REMOVE) protected String fpl;
@Argument(required = true, activator = OptionActivators.UndeployNameActivator.class, completer = EnableCommand.NameCompleter.class) public String name;
public class CdCommand extends PmSessionCommand { @Argument(description = HelpDescriptions.CD_PATH) private File path;
@Argument(required = true, activator = OptionActivators.UndeployNameActivator.class, completer = EnableCommand.NameCompleter.class) public String name;