<commit_before>// Create an instance of the common script to operate on
File sourceFile = new File("config/groovy/common.groovy")
Class sourceClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(sourceFile)
GroovyObject common = (GroovyObject) sourceClass.newInstance()

// User didn't enter a type (example: `groovyw`)
if (args.length == 0) {
    println "You need to supply some parameters! See 'groovyw usage' for details"
    return
}

// If the user literally requested usage text then print it!
if (args[0] == "usage") {
    printUsage()
    return
}

// User entered a type that doesn't correspond to a script (example: `groovyw fish`)
if (!new File("config/groovy/" + args[0] + ".groovy").exists()) {
    println "That type '" + args[0] + "' did not correspond to a defined utility type script. Typo? See 'groovyw usage'"
    return
}

// User didn't enter a sub-command (example: `groovyw module`)
if (args.length == 1) {
    println "You need to supply a sub-command as well as a type of object to act on. See 'groovyw usage' for details"
    return
}

// Initialize the type target to load in things specific to that type
common.initialize(args[0])
itemType = common.itemType

// At this point we have the type script loaded, so don't need that arg anymore
String[] cleanerArgs = args.drop(1)

excludedItems = common.excludedItems
targetDirectory = common.targetDirectory

def recurse = false
switch (cleanerArgs[0]) {
    case "recurse":
        recurse = true
        println "We're retrieving recursively (all the things depended on too)"
// We just fall through here to the get logic after setting a boolean
//noinspection GroovyFallthrough
    case "get":
        println "Preparing to get $itemType"
        //println "cleanerArgs is $cleanerArgs"
        if (cleanerArgs.length == 1) {
            def itemString = common.getUserString("Enter what to get - separate multiple with spaces, CapiTaliZation MatterS): ")
            println "User wants: $itemString"
            String[] itemList = itemString.split("\\s+")
            common.retrieve itemList, recurse
        } else {
            // Note: processCustomRemote also drops one of the array elements from cleanerArgs
            cleanerArgs = common.processCustomRemote(cleanerArgs)
            ArrayList<String> selectedItems = new ArrayList<String>()

            for (String arg : cleanerArgs) {
                //println "Checking arg $arg"
                if (!arg.contains('*') && !arg.contains('?')) {
                    println "Got into the non-wilcard option to fetch a fully specified item for $arg"
                    selectedItems.add(arg)
                } else {
                    println "Got into the wildcard option to fetch something matching a pattern for $arg, may need to cache first"
                    common.cacheItemList()
                    selectedItems.addAll(common.retrieveAvalibleItemsWithWildcardMatch(arg));
                }
            }
            common.unCacheItemList()

            common.retrieve(((String[]) selectedItems.toArray()), recurse)
        }
        break
    case "get-all":
        println "Preparing to get all modules"
        ArrayList<String> selectedItems = new ArrayList<String>()
        common.cacheItemList()
        selectedItems.addAll(common.retrieveAvalibleItemsWithWildcardMatch("*"));
        common.unCacheItemList()
        common.retrieve(((String[]) selectedItems.toArray()), recurse)
        break
    case "create":
        println "We're doing a create"
        String name
        if (cleanerArgs.length > 2) {
            println "Received more than one argument. Aborting."
            break
        } else if (cleanerArgs.length == 2) {
            // User already submitted the name of what they want to create
            name = cleanerArgs[1]
        } else {
            // User hasn't entered a name yet so request it
            name = getUserString("Enter $itemType name: ")
        }
        println "User wants to create a $itemType named: $name"
        common.createItem(name)
        println "Created $itemType named $name"
        break

    case "update":
        println "We're updating $itemType"
        String[] itemList
        if (cleanerArgs.length == 1) {
            def itemString = common.getUserString("Enter what to update - separate multiple with spaces, CapiTaliZation MatterS): ")
            itemList = itemString.split("\\s+")
        } else {
            itemList = cleanerArgs.drop(1)
        }
        println "List of items to update: $itemList"
        for (String item : itemList) {
            common.updateItem(item)
        }
        break

    case "update-all":
        println "We're updating every $itemType"
        println "List of local entries: ${common.retrieveLocalItems()}"
        if (cleanerArgs.contains("--continue")) {
            for (item in common.retrieveLocalItems()) {
                common.updateItem(item, true)
            }
        } else {
            for (item in common.retrieveLocalItems()) {
                common.updateItem(item)
            }
        }
        break

    case "add-remote":
        if (cleanerArgs.length == 3) {
            itemName = cleanerArgs[1]
            remoteName = cleanerArgs[2]
            println "Adding git remote for $itemType $itemName"
            common.addRemote(itemName, remoteName)<commit_msg>Update config/groovy/util.groovy<commit_after>// Create an instance of the common script to operate on
File sourceFile = new File("config/groovy/common.groovy")
Class sourceClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(sourceFile)
GroovyObject common = (GroovyObject) sourceClass.newInstance()

// User didn't enter a type (example: `groovyw`)
if (args.length == 0) {
    println "You need to supply some parameters! See 'groovyw usage' for details"
    return
}

// If the user literally requested usage text then print it!
if (args[0] == "usage") {
    printUsage()
    return
}

// User entered a type that doesn't correspond to a script (example: `groovyw fish`)
if (!new File("config/groovy/" + args[0] + ".groovy").exists()) {
    println "That type '" + args[0] + "' did not correspond to a defined utility type script. Typo? See 'groovyw usage'"
    return
}

// User didn't enter a sub-command (example: `groovyw module`)
if (args.length == 1) {
    println "You need to supply a sub-command as well as a type of object to act on. See 'groovyw usage' for details"
    return
}

// Initialize the type target to load in things specific to that type
common.initialize(args[0])
itemType = common.itemType

// At this point we have the type script loaded, so don't need that arg anymore
String[] cleanerArgs = args.drop(1)

excludedItems = common.excludedItems
targetDirectory = common.targetDirectory

def recurse = false
switch (cleanerArgs[0]) {
    case "recurse":
        recurse = true
        println "We're retrieving recursively (all the things depended on too)"
// We just fall through here to the get logic after setting a boolean
//noinspection GroovyFallthrough
    case "get":
        println "Preparing to get $itemType"
        //println "cleanerArgs is $cleanerArgs"
        if (cleanerArgs.length == 1) {
            def itemString = common.getUserString("Enter what to get - separate multiple with spaces, CapiTaliZation MatterS): ")
            println "User wants: $itemString"
            String[] itemList = itemString.split("\\s+")
            common.retrieve itemList, recurse
        } else {
            // Note: processCustomRemote also drops one of the array elements from cleanerArgs
            cleanerArgs = common.processCustomRemote(cleanerArgs)
            ArrayList<String> selectedItems = new ArrayList<String>()

            for (String arg : cleanerArgs) {
                //println "Checking arg $arg"
                if (!arg.contains('*') && !arg.contains('?')) {
                    println "Got into the non-wilcard option to fetch a fully specified item for $arg"
                    selectedItems.add(arg)
                } else {
                    println "Got into the wildcard option to fetch something matching a pattern for $arg, may need to cache first"
                    common.cacheItemList()
                    selectedItems.addAll(common.retrieveAvalibleItemsWithWildcardMatch(arg));
                }
            }
            common.unCacheItemList()

            common.retrieve(((String[]) selectedItems.toArray()), recurse)
        }
        break
    case "get-all":
        println "Preparing to get all modules"
        ArrayList<String> selectedItems = new ArrayList<String>()
        common.cacheItemList()
        selectedItems.addAll(common.retrieveAvalibleItemsWithWildcardMatch("*"));
        common.unCacheItemList()
        common.retrieve(((String[]) selectedItems.toArray()), recurse)
        break
    case "create":
        println "We're doing a create"
        String name
        if (cleanerArgs.length > 2) {
            println "Received more than one argument. Aborting."
            break
        } else if (cleanerArgs.length == 2) {
            // User already submitted the name of what they want to create
            name = cleanerArgs[1]
        } else {
            // User hasn't entered a name yet so request it
            name = getUserString("Enter $itemType name: ")
        }
        println "User wants to create a $itemType named: $name"
        common.createItem(name)
        println "Created $itemType named $name"
        break

    case "update":
        println "We're updating $itemType"
        String[] itemList
        if (cleanerArgs.length == 1) {
            def itemString = common.getUserString("Enter what to update - separate multiple with spaces, CapiTaliZation MatterS): ")
            itemList = itemString.split("\\s+")
        } else {
            itemList = cleanerArgs.drop(1)
        }
        println "List of items to update: $itemList"
        for (String item : itemList) {
            common.updateItem(item)
        }
        break

    case "update-all":
        println "We're updating every $itemType"
        println "List of local entries: ${common.retrieveLocalItems()}"
        def skipRecentlyUpdated = cleanerArgs.contains("--continue")
        for (item in common.retrieveLocalItems()) {
        	common.updateItem(item, skipRecentlyUpdated)
        }
        break

    case "add-remote":
        if (cleanerArgs.length == 3) {
            itemName = cleanerArgs[1]
            remoteName = cleanerArgs[2]
            println "Adding git remote for $itemType $itemName"
            common.addRemote(itemName, remoteName)
{'fraction_non_alphanumeric': 0.09692206941715782, 'fraction_numerical': 0.00318084011600711, 'mean_word_length': 2.385053831538949, 'pattern_counts': {'":': 14, '<': 11, '<?xml version=': 0, '>': 13, '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': '483619', 'n_tokens_mistral': 2957, 'n_tokens_neox': 2786, 'n_words': 959}