<commit_before>from octopus.core import app
from octopus.lib import plugin, cli
import sys

command = sys.argv[1]
args = sys.argv[2:]

for name, path in app.config.get("CLI_SCRIPTS", {}).iteritems():
    ran = False
    if name == command:
        # get an instance of the script
        klazz = plugin.load_class(path)
        inst = klazz()

        # check that it can legitimately be run
        if not isinstance(inst, cli.Script):
            print command, "is not a legitimate octopus script - must extend from octopus.lib.cli.Script"
            exit()

        # run it
        ran = True
        klazz().run(args)

    if not ran:
        print command, "- command not found"<commit_msg>ensure that command line scripts get initialise run first<commit_after>from octopus.core import app, initialise
from octopus.lib import plugin, cli
import sys

command = sys.argv[1]
args = sys.argv[2:]

for name, path in app.config.get("CLI_SCRIPTS", {}).iteritems():
    ran = False
    if name == command:
        # get an instance of the script
        klazz = plugin.load_class(path)
        inst = klazz()

        # check that it can legitimately be run
        if not isinstance(inst, cli.Script):
            print command, "is not a legitimate octopus script - must extend from octopus.lib.cli.Script"
            exit()

        # ensure the app is initialised
        initialise()

        # run it
        ran = True
        klazz().run(args)

    if not ran:
        print command, "- command not found"
{'fraction_non_alphanumeric': 0.09247027741083223, 'fraction_numerical': 0.002642007926023778, 'mean_word_length': 2.3078602620087336, 'pattern_counts': {'":': 0, '<': 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': '3579640', 'n_tokens_mistral': 450, 'n_tokens_neox': 434, 'n_words': 160}