Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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()
2 changes: 1 addition & 1 deletion cli/commands/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
app = typer.Typer(help="Hello command group")


@app.command()
@app.callback(invoke_without_command=True)
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.

Changing greet from a command to a callback removes the hello greet subcommand, but tests still invoke hello greet; this will cause those tests (and existing CLI usage) to fail. Either revert to @app.command() (and possibly add a separate callback if needed) or update tests and documentation to invoke hello (without greet) and use --name when desired.

Suggested change
@app.callback(invoke_without_command=True)
@app.command()

Copilot uses AI. Check for mistakes.
def greet(name: str = "World"):
"""Say hello to someone."""
typer.echo(f"Hello, {name}!")
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.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 @@ -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
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.

These assertions expect strings without trailing periods, but list.py currently outputs periods for ls, cd, and pwd; the test will fail. Align either the test expectations (add periods) or the list.py literals (remove periods) consistently across all entries.

Suggested change
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
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

Copilot uses AI. Check for mistakes.


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