Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import typer

from commands import hello, version
from commands import hello, list, version

app = typer.Typer(help="101 Linux Commands CLI 🚀")
app.add_typer(hello.app, name="hello")
app.add_typer(list.app, name="list")
app.add_typer(version.app, name="version")


Expand Down
15 changes: 15 additions & 0 deletions cli/commands/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import typer

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


@app.callback(invoke_without_command=True)
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 @@ -58,6 +58,20 @@ def test_hello_help():
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 "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


def test_version_command():
"""Test the version command"""
result = subprocess.run(
Expand Down Expand Up @@ -88,6 +102,7 @@ def test_version_show_command():
test_hello_command()
test_hello_command_with_name()
test_hello_help()
test_list_command()
test_version_command()
test_version_show_command()
print("✅ All tests passed!")