"""Example function for walking a file system.

Name: Chris Mayfield
Date: 11/19/2025
"""

import os
import sys


def print_files(path, indent=0):
    """Print all files reachable from the given path.

    Each level of the file system should be indented by four spaces.
    Print a colon after paths that represent a folder (directory).

    Args:
        path (str): The starting (current) location.
        indent (int): How many leading spaces to print.
    """
    print(" " * indent, end="")
    basename = os.path.basename(path)

    # Base case: regular file
    if os.path.isfile(path):
        print(basename)
        return

    # Recursive case: folder
    print(basename + ":")
    for entry in sorted(os.listdir(path)):
        entry_path = os.path.join(path, entry)
        print_files(entry_path, indent + 4)


if __name__ == "__main__":
    if len(sys.argv) == 1:
        # no arguments; use current directory
        print_files(os.getcwd())
    else:
        # use the first command-line argument
        print_files(sys.argv[1])
