<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Main command line tool to nuke a directory.
"""
import os
import os.path as osp
import shutil
import argparse
from clint.textui import colored, puts, prompt


def nuke(directory):
    puts("Nuking " + colored.cyan(directory))
        
    try:
        # Go to the parent directory
        os.chdir(osp.basename(directory))
        puts(osp.dirname(directory))

        # Nuke the directory
        shutil.rmtree(directory)
        os.mkdir(directory)
    except (FileNotFoundError,):
        puts(colored.yellow("Nuke target does not exist..."))
    except (Exception,):
        puts(colored.yellow("Nuking failed..."))


def _argparse():
    parser = argparse.ArgumentParser("nuke")
    parser.add_argument("directory", nargs='?', default=os.getcwd(), help="Directory to nuke! Default is current working directory")
    parser.add_argument("-y", help="Confirm nuking", action="store_true")
    args = parser.parse_args()
    return args


if __name__ == "__main__":
    args = _argparse()
    directory = osp.abspath(args.directory)
    if prompt.yn("Are you sure you want to nuke this directory?"):
        nuke(directory)<commit_msg>cmd argument to confirm nuking<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Main command line tool to nuke a directory.
"""
import os
import os.path as osp
import shutil
import argparse
from clint.textui import colored, puts, prompt


def nuke(directory):
    puts("Nuking " + colored.cyan(directory))
        
    try:
        # Go to the parent directory
        os.chdir(osp.basename(directory))
        puts(osp.dirname(directory))

        # Nuke the directory
        shutil.rmtree(directory)
        os.mkdir(directory)
    except (FileNotFoundError,):
        puts(colored.yellow("Nuke target does not exist..."))
    except (Exception,):
        puts(colored.yellow("Nuking failed..."))


def _argparse():
    parser = argparse.ArgumentParser("nuke")
    parser.add_argument("directory", nargs='?', default=os.getcwd(), help="Directory to nuke! Default is current working directory")
    parser.add_argument("-y", help="Confirm nuking", action="store_true")
    args = parser.parse_args()
    return args


if __name__ == "__main__":
    args = _argparse()
    directory = osp.abspath(args.directory)
    if args.y or prompt.yn("Are you sure you want to nuke this directory?"):
        nuke(directory)
{'fraction_non_alphanumeric': 0.12864775996711877, 'fraction_numerical': 0.0016440608302507192, 'mean_word_length': 3.270175438596491, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6823370', 'n_tokens_mistral': 749, 'n_tokens_neox': 741, 'n_words': 199}