<commit_before>/**
 *  Copyright 2005-2014 Red Hat, Inc.
 *
 *  Red Hat licenses this file to you under the Apache License, version
 *  2.0 (the "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 *  implied.  See the License for the specific language governing
 *  permissions and limitations under the License.
 */
package io.fabric8.process.manager.commands;

import io.fabric8.process.manager.Installation;
import io.fabric8.process.manager.ProcessManager;
import io.fabric8.process.manager.commands.support.ProcessControlCommandSupport;
import org.apache.felix.gogo.commands.Command;

/**
 */
@Command(name = "unstall", scope = "process", description = "Uninstalls a managed process from this container.")
public class UninstallAction extends ProcessControlCommandSupport {

    protected UninstallAction(ProcessManager processManager) {
        super(processManager);
    }

    @Override
    protected void doControlCommand(Installation installation) throws Exception {
        getProcessManager().uninstall(installation);
    }
}<commit_msg>#1695: process:uninstall should detect if the process is alive. Only if using --force we uninstall if its avlive.<commit_after>/**
 *  Copyright 2005-2014 Red Hat, Inc.
 *
 *  Red Hat licenses this file to you under the Apache License, version
 *  2.0 (the "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 *  implied.  See the License for the specific language governing
 *  permissions and limitations under the License.
 */
package io.fabric8.process.manager.commands;

import io.fabric8.process.manager.Installation;
import io.fabric8.process.manager.ProcessManager;
import io.fabric8.process.manager.commands.support.ProcessControlCommandSupport;
import org.apache.felix.gogo.commands.Command;
import org.apache.felix.gogo.commands.Option;

/**
 */
@Command(name = "unstall", scope = "process", description = "Uninstalls a managed process from this container.")
public class UninstallAction extends ProcessControlCommandSupport {

    @Option(name="-f", aliases={"--force"}, required = false, description = "Forces uninstalling even if the process is still alive")
    protected boolean force = false;

    protected UninstallAction(ProcessManager processManager) {
        super(processManager);
    }

    @Override
    protected void doControlCommand(Installation installation) throws Exception {
        if (!force && installation.getActivePid() != null) {
            System.out.println("The process is alive and cannot be uninstalled. Stop the process before uninstalling, or use the --force option.");
        } else {
            getProcessManager().uninstall(installation);
        }
    }
}
{'fraction_non_alphanumeric': 0.08828828828828829, 'fraction_numerical': 0.010810810810810811, 'mean_word_length': 3.9716417910447763, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2149108', 'n_tokens_mistral': 880, 'n_tokens_neox': 856, 'n_words': 319}