@argh_named("script")
    @arg_verbose
    @argh.arg('script', metavar="FILE", type=str,
              help='script file path or "-" (a single minus-sign) for stdin')
    @argh.arg('variable', type=str, nargs="*", help="'name=[type:]value'")
    @expects_obj
    def handle_script(self, arg):
        """run commands from a script file"""
        try:
            if arg.script != "-":
                script_text = open(arg.script).read()
            else:
                script_text = sys.stdin.read()
        except (OSError, IOError) as error:
            raise errors.Error("%s: %s" % (error.__class__.__name__, error))

        variables = dict(util.parse_prop(var) for var in arg.variable)
        variables['current_script_dir'] = os.path.dirname(arg.script)

        match = re.search(r"^\s*#\s+poni\.template\s*:\s*(\w+)", script_text, re.MULTILINE)
        engine = match.group(1) if match else "cheetah"
        script_text = template.render(engine=engine, source_text=script_text, variables=variables)
        lines = script_text.splitlines()

        def wrap(args):
            if " " in args:
                return repr(args)
            else:
                return args

        def set_repo_path(sub_arg):
            self.tune_arg_namespace(sub_arg)
            sub_arg.root_dir = arg.root_dir

        lines = self.preprocess_script_lines(lines)

        for i, line in enumerate(lines):
            args = shlex.split(line, comments=True)
            if not args:
                continue

            if arg.verbose:
                print("$ " + " ".join(wrap(a) for a in args))

            # strip arguments following "--"
            # TODO: this code is now in two places, refactor
            namespace = argparse.Namespace()
            try:
                extra_loc = args.index("--")
                namespace.extras = args[extra_loc + 1:]
                args = args[:extra_loc]
            except __HOLE__:
                namespace.extras = []

            start = time.time()
            self.parser.dispatch(argv=args, pre_call=set_repo_path,
                                 namespace=namespace)
            stop = time.time()
            if namespace.time_op:  # pylint: disable=E1101
                self.task_times.add_task("L%d" % (i + 1), line, start, stop, args=args)
dataset/ETHPy150Open ohmu/poni/poni/tool.py/Tool.handle_script