/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF 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 org.apache.camel.dsl.jbang.core.commands.process;

import java.io.File;
import java.util.List;

import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
import org.apache.camel.util.FileUtil;
import picocli.CommandLine;
import picocli.CommandLine.Command;

@Command(name = "stop", description = "Shuts down a running Camel integration")
public class StopProcess extends ProcessBaseCommand {

    @CommandLine.Parameters(description = "Name or pid of running Camel integration", arity = "0..1")
    String name;

    @CommandLine.Option(names = { "--all" },
                        description = "To shutdown all running Camel integrations")
    boolean all;

    public StopProcess(CamelJBangMain main) {
        super(main);
    }

    @Override
    public Integer call() throws Exception {
        if (!all && name == null) {
            return 0;
        } else if (all) {
            name = "*";
        }

        List<Long> pids = findPids(name);

        // stop by deleting the pid file
        for (Long pid : pids) {
            File dir = new File(System.getProperty("user.home"), ".camel");
            File pidFile = new File(dir, "" + pid);
            System.out.println("Shutting down Camel integration (pid: " + pid + ")");
            FileUtil.deleteFile(pidFile);
        }

        return 0;
    }

}

@@ -1470,16 +1470,161 @@
 n all;%0A%0A
+    @CommandLine.Option(names = %7B %22--kill%22 %7D,%0A                        description = %22To force killing the process (SIGKILL)%22)%0A    boolean kill;%0A%0A
     publ
@@ -1657,24 +1657,24 @@
 ain main) %7B%0A
-
         supe
@@ -2111,16 +2111,56 @@
 + pid);%0A
+            if (pidFile.exists()) %7B%0A    
         
@@ -2245,24 +2245,28 @@
             
+    
 FileUtil.del
@@ -2283,16 +2283,276 @@
 dFile);%0A
+            %7D%0A            if (kill) %7B%0A                ProcessHandle.of(pid).ifPresent((ph) -%3E %7B%0A                    System.out.println(%22Killing Camel integration (pid: %22 + pid + %22)%22);%0A                    ph.destroyForcibly();%0A                %7D);%0A            %7D%0A
         

Add -kill to camel stop command in camel-jbang