Galaxie Shell 0.2.6 documentation


Navigation:   | Index   | Search   | Top   | Up   |
Table of Content: |

© Copyright 2020-2024, Galaxie Shell Team.

Top » Module code » glxshell.utilities.time

Source code for glxshell.utilities.time

# inspired by: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/time.html
import sys

from glxshell.lib.argparse import ArgumentParser

parser_time = ArgumentParser(
    name="time - time a simple command",
    description="The time utility shall invoke the utility named by the utility operand with arguments supplied as "
                "the argument operands and write a message to standard error that lists timing statistics for the "
                "utility. ",
    synopsis=["time [-p] utility [argument...]"],
    exit_status={
        "1-125": "An error occurred in the time utility.",
        "126": "The utility specified by utility was found but could not be invoked.",
        "127": "The utility specified by utility could not be found.",
    }
)
parser_time.add_argument(
    "-p",
    dest="p",
    action="store_true",
    help="Write the timing output to standard error",
)

parser_time.add_argument(
    "utility",
    nargs="?",
    help="The name of a utility that is to be invoked.",
)

parser_time.add_argument(
    "argument",
    nargs="?",
    help="Any string to be supplied as an argument when invoking the utility named by the utility operand.",
)

[docs] def glxsh_time(p=None, utility=None, argument=None, line=None, shell=None): from time import time from os import times exit_code = 0 en_time = times() start = time() exit_code = shell.onecmd(line) en_time = times() sys.stderr.write("real %f\nuser %f\nsys %f\n" % (time() - start, en_time.user, en_time.system )) sys.stderr.flush() return exit_code

Top » Module code » glxshell.utilities.time

© Copyright 2020-2024, Galaxie Shell Team.
This page is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (CC BY-NC-SA 4.0).
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
See History and License for more information.

Last updated on None.
Created using Sphinx 8.0.2.