def print_cmd(line, commands_file, todo_only, mode='a'):
    """
    Print unix command-line depending on the choosen output and DRS action.

    :param str line: The command-line to write.
    :param str commands_file: The output file to write command-lines, None if not.
    :param boolean todo_only: True to only print Unix command-lines to apply (i.e., as dry-run)
    :param str mode: File open() mode

    """
    if commands_file and todo_only:
        with open(commands_file, mode) as f:
            f.write('{}\n'.format(line))
    else:
        print(line)
