#!/usr/bin/env python

import argparse
import sys

import jwst.stpipe as stpipe
from jwst.stpipe import Step
from jwst.stpipe import utilities

if __name__ == '__main__':

    if '--version' in sys.argv:
        sys.stdout.write("%s\n" % stpipe.__version__)
        sys.exit(0)

    parser = argparse.ArgumentParser(
        description='Display the spec file for a given stpipe step')
    parser.add_argument(
        'class', type=str, nargs=1, help='The name of the Step class')

    args = parser.parse_args()

    step_class_name = getattr(args, 'class')[0]
    try:
        step_class = utilities.import_class(step_class_name, Step)
    except Exception as e:
        print(e)
        sys.exit(1)

    step_class.print_configspec()
