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

# http://multivax.com/last_question.html

"""main

Usage:
    main.py --spec FILE
    main.py --interactive
    main.py --package-dir
    main.py --version
    main.py (-h | --help)

Options:
    -h, --help              Shows this help
    --version               Prints current version
    --spec FILE             YAML file with the environment specification [default: spec.yaml]
    --package-dir           Name of the exercise package directory

"""

from docopt import docopt
from getpass import getpass
import logging

from automation.model import Spec
from automation.parser import parse_file, verify_syntax


__version__ = "0.4.0"
__author__  = "<NAME>"
__email__   = "<<EMAIL>>"


# TODO: setup.py file to enable easy installation using pip (see: https://github.com/imsweb/ezmomi/blob/master/setup.py)
# TODO: license?
def main():

    if args["--interactive"]:
        host = input("Hostname of vCenter server: ")
        port = input("Port of vCenter server: ")
        user = input("Username to login with: ")
        pswd = getpass("Password to login with: ")

    if args["--spec"]:
        spec = parse_file(args["--spec"])
        logging.info("Successfully ingested specification")
        logging.info("Checking syntax...")
        if verify_syntax(spec):
            logging.info("Syntax check successful!")
        else:
            logging.error("Syntax check failed!")
            return 1
        # model = Spec(spec["metadata"])


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG,
                        format="[%(asctime)s] %(name)-12s %(levelname)-8s %(message)s",
                        datefmt="%y-%m-%d %H:%M:%S",
                        filename="environment-creator.log",
                        filemode='w')
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    formatter = logging.Formatter("%(levelname)-12s %(message)s")
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)

    args = docopt(__doc__, version=__version__, help=True)
    main()<commit_msg>Main.py argument changes<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# http://multivax.com/last_question.html

"""Program used to create cybersecurity educational environments from formal specifications.

Usage:
    main.py --check-syntax FILE
    main.py --spec FILE
    main.py --package-dir NAME
    main.py --version
    main.py (-h | --help)

Options:
    -h, --help                  Shows this help
    --version                   Prints current version
    -c, --check-syntax FILE     Validates syntax is valid per specification
    -s, --spec FILE             YAML file with the environment specification
    -p, --package-dir NAME      Filepath of the exercise package directory

"""

from docopt import docopt
import logging

from automation.model import Spec
from automation.parser import parse_file, verify_syntax


__version__ = "0.4.0"
__author__  = "<NAME>"
__email__   = "<<EMAIL>>"


# TODO: setup.py file to enable easy installation using pip (see: https://github.com/imsweb/ezmomi/blob/master/setup.py)
# TODO: license?
def main():

    if args["--spec"]:
        spec = parse_file(args["--spec"])
        logging.info("Successfully ingested %s", str(args["--spec"]))
        logging.info("Checking syntax...")
        if verify_syntax(spec):
            logging.info("Syntax check successful!")
        else:
            logging.error("Syntax check failed!")
            return 1
        # model = Spec(spec["metadata"])

    elif args["--check-syntax"]:
        spec = parse_file(args["--check-syntax"])
        logging.info("Successfully ingested %s", str(args["--check-syntax"]))
        logging.info("Checking syntax...")
        if verify_syntax(spec):
            logging.info("Syntax check successful!")
        else:
            logging.error("Syntax check failed!")
            exit(1)

    elif args["--package-dir"]:
        logging.error("CURRENTLY UNSUPPORTED")


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG,
                        format="[%(asctime)s] %(name)-12s %(levelname)-8s %(message)s",
                        datefmt="%y-%m-%d %H:%M:%S",
                        filename="environment-creator.log",
                        filemode='w')
    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    formatter = logging.Formatter("%(levelname)-12s %(message)s")
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)

    args = docopt(__doc__, version=__version__, help=True)
    main()
{'fraction_non_alphanumeric': 0.1368624919302776, 'fraction_numerical': 0.004949429739616957, 'mean_word_length': 2.437869822485207, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '3443993', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1322, 'n_words': 331}