class DetachClusterCommand extends ElasticsearchNodeCommand {

    public static final String NODE_DETACHED_MSG = "Node was successfully detached from the cluster";
    public static final String CONFIRMATION_MSG =
        DELIMITER +
            "\n" +
            "You should only run this tool if you have permanently lost all of the\n" +
            "master-eligible nodes in this cluster and you cannot restore the cluster\n" +
            "from a snapshot, or you have already unsafely bootstrapped a new cluster\n" +
            "by running `crate-node unsafe-bootstrap` on a master-eligible\n" +
            "node that belonged to the same cluster as this node. This tool can cause\n" +
            "arbitrary data loss and its use should be your last resort.\n" +
            "\n" +
            "Do you want to proceed?\n";

    public DetachClusterCommand() {
        super("Detaches this node from its cluster, allowing it to unsafely join a new cluster");
    }


    @Override
    protected void processNodePaths(Terminal terminal, Path[] dataPaths, OptionSet options, Environment env) throws IOException {<FILL_FUNCTION_BODY>}

    // package-private for tests
    static Metadata updateMetadata(Metadata oldMetadata) {
        final CoordinationMetadata coordinationMetadata = CoordinationMetadata.builder()
                .lastAcceptedConfiguration(CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_MASTER)
                .lastCommittedConfiguration(CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_MASTER)
                .term(0)
                .build();
        return Metadata.builder(oldMetadata)
                .coordinationMetadata(coordinationMetadata)
                .clusterUUIDCommitted(false)
                .build();
    }

    //package-private for tests
    static long updateCurrentTerm() {
        return 0;
    }
}

        final PersistedClusterStateService persistedClusterStateService = createPersistedClusterStateService(env.settings(), dataPaths);

        terminal.println(Terminal.Verbosity.VERBOSE, "Loading cluster state");
        final ClusterState oldClusterState = loadTermAndClusterState(persistedClusterStateService, env).v2();
        final ClusterState newClusterState = ClusterState.builder(oldClusterState)
            .metadata(updateMetadata(oldClusterState.metadata())).build();
        terminal.println(Terminal.Verbosity.VERBOSE,
                         "[old cluster state = " + oldClusterState + ", new cluster state = " + newClusterState + "]");

        confirm(terminal, CONFIRMATION_MSG);

        try (PersistedClusterStateService.Writer writer = persistedClusterStateService.createWriter()) {
            writer.writeFullStateAndCommit(updateCurrentTerm(), newClusterState);
        }

        terminal.println(NODE_DETACHED_MSG);
    
<methods>public void <init>(java.lang.String) ,public static org.elasticsearch.cluster.ClusterState clusterState(org.elasticsearch.env.Environment, org.elasticsearch.gateway.PersistedClusterStateService.OnDiskState) ,public static org.elasticsearch.gateway.PersistedClusterStateService createPersistedClusterStateService(org.elasticsearch.common.settings.Settings, java.nio.file.Path[]) throws java.io.IOException,public final void execute(org.elasticsearch.cli.Terminal, OptionSet, org.elasticsearch.env.Environment) throws java.lang.Exception,public static Tuple<java.lang.Long,org.elasticsearch.cluster.ClusterState> loadTermAndClusterState(org.elasticsearch.gateway.PersistedClusterStateService, org.elasticsearch.env.Environment) throws java.io.IOException<variables>public static final java.lang.String ABORTED_BY_USER_MSG,public static final java.lang.String CS_MISSING_MSG,protected static final java.lang.String DELIMITER,public static final java.lang.String FAILED_TO_OBTAIN_NODE_LOCK_MSG,private static final Logger LOGGER,protected static final org.elasticsearch.common.xcontent.NamedXContentRegistry NAMED_X_CONTENT_REGISTRY,public static final java.lang.String NO_NODE_FOLDER_FOUND_MSG,public static final java.lang.String NO_NODE_METADATA_FOUND_MSG,public static final java.lang.String STOP_WARNING_MSG