def add_common_arguments(parser, nargs=1):
    """Populate the given argparse.ArgumentParser with arguments.

    This function can be used to centralize the definition of commons argparse
    arguments and avoid the duplication of these definitions among the
    executable scripts.

    The following arguments are added to the parser:

    - **verbose** (boolean): verbose mode
    - **debug** (boolean): debug mode
    - **plot** (boolean): plot images
    - **saveplot** (string): the output file where to save plotted images
    - **fileargs** (file paths): the files image to process

    Parameters
    ----------
    parser : argparse.ArgumentParser
        The parser to populate.

    Returns
    -------
    argparse.ArgumentParser
        Return the populated ArgumentParser object.
    """
    parser.add_argument('--verbose', '-v', action='store_true', help=
        'Verbose mode.')
    parser.add_argument('--debug', action='store_true', help='Debug mode.')
    parser.add_argument('--plot', action='store_true', help='Plot images.')
    parser.add_argument('--saveplot', default=None, metavar='FILE', help=
        'The output file where to save plotted images.')
    parser.add_argument('fileargs', nargs=nargs, metavar='FILE', help=
        'The files image to process.')
    return parser
