Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/cli.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import typer

from commands import hello
from commands import list

# Create the root CLI app
app = typer.Typer(help="101 Linux Commands CLI 🚀")

# Register subcommands
app.add_typer(hello.app, name="hello")
app.add_typer(list.app, name="list")
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing a module named list masks the built-in list type in this scope, reducing clarity; renaming the module (e.g., commands_list) or importing with an alias (from commands import list as list_commands) would avoid overshadowing and make intent clearer. Update the registration accordingly (app.add_typer(list_commands.app, name="list")).

Suggested change
from commands import list
# Create the root CLI app
app = typer.Typer(help="101 Linux Commands CLI 🚀")
# Register subcommands
app.add_typer(hello.app, name="hello")
app.add_typer(list.app, name="list")
from commands import list as list_commands
# Create the root CLI app
app = typer.Typer(help="101 Linux Commands CLI 🚀")
# Register subcommands
app.add_typer(hello.app, name="hello")
app.add_typer(list_commands.app, name="list")

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing a module named list masks the built-in list type in this scope, reducing clarity; renaming the module (e.g., commands_list) or importing with an alias (from commands import list as list_commands) would avoid overshadowing and make intent clearer. Update the registration accordingly (app.add_typer(list_commands.app, name="list")).

Suggested change
from commands import list
# Create the root CLI app
app = typer.Typer(help="101 Linux Commands CLI 🚀")
# Register subcommands
app.add_typer(hello.app, name="hello")
app.add_typer(list.app, name="list")
from commands import list as list_commands
# Create the root CLI app
app = typer.Typer(help="101 Linux Commands CLI 🚀")
# Register subcommands
app.add_typer(hello.app, name="hello")
app.add_typer(list_commands.app, name="list")

Copilot uses AI. Check for mistakes.

if __name__ == "__main__":
app()
14 changes: 14 additions & 0 deletions cli/commands/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import typer

app = typer.Typer(help="List the commands available on Linux.")

@app.command()
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test invokes cli.py list expecting the command descriptions to print, but this code defines a Typer sub-app with a subcommand also named list; executing cli.py list (without the subcommand) will show the group help, not run the function. To make cli.py list produce the desired output, either move the logic to a top-level command (remove the nested Typer and register the function directly) or change this to @app.callback() so it runs when no subcommand is provided.

Suggested change
@app.command()
@app.callback()

Copilot uses AI. Check for mistakes.
def list():
commands = [
"ls - List directory contents.",
"cd - Change directory.",
"pwd - Print working directory.",
Comment on lines +9 to +11
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent punctuation: first three entries end with a period while the last does not, and this inconsistency conflicts with test expectations (which omit periods). Standardize all entries (either all with periods or all without) and sync the tests accordingly.

Suggested change
"ls - List directory contents.",
"cd - Change directory.",
"pwd - Print working directory.",
"ls - List directory contents",
"cd - Change directory",
"pwd - Print working directory",

Copilot uses AI. Check for mistakes.
"cat - Concatenate and display files.",
]
for command in commands:
typer.echo(command)
15 changes: 15 additions & 0 deletions cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,25 @@ def test_hello_help():
assert result.returncode == 0
assert "Hello command group" in result.stdout

def test_list_command():
"""Test the list command."""
result = subprocess.run(
[sys.executable, "cli.py", "list"],
capture_output=True,
text=True,
cwd=os.path.dirname(__file__),
)
assert result.returncode == 0
assert "ls - List directory contents." in result.stdout
assert "cd - Change directory." in result.stdout
assert "pwd - Print working directory." in result.stdout
assert "cat - Concatenate and display files." in result.stdout


if __name__ == "__main__":
test_cli_help()
test_hello_command()
test_hello_command_with_name()
test_hello_help()
test_list_command()
print("✅ All tests passed!")
Loading