Skip to content
Open
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
53 changes: 43 additions & 10 deletions cli/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,47 @@

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.",
"cat - Concatenate and display files.",
]
for command in commands:
typer.echo(command)
def list(ctx: typer.Context, verbose: bool = typer.Option(False, "--verbose", help="Show examples for each command")):
"""
Display a list of commonly used Linux commands.
"""
commands = {
"ls": "List directory contents",
"cd": "Change directory",
"pwd": "Print working directory",
"cat": "Concatenate and display files",
"mkdir": "Make directories",
"rm": "Remove files or directories",
"cp": "Copy files and directories",
"mv": "Move or rename files and directories",
"touch": "Create empty files",
"grep": "Search text using patterns",
"chmod": "Change file permissions",
"man": "Display manual pages",
}

examples = {
"ls": "ls -l",
"cd": "cd /home/user",
"pwd": "pwd",
"cat": "cat file.txt",
"mkdir": "mkdir new_folder",
"rm": "rm file.txt",
"cp": "cp source.txt dest.txt",
"mv": "mv old.txt new.txt",
"touch": "touch newfile.txt",
"grep": "grep 'hello' file.txt",
"chmod": "chmod +x script.sh",
"man": "man ls",
}

typer.echo("\n📜 Common Linux Commands:\n")
for cmd, desc in commands.items():
typer.echo(f"🔹 {cmd:<6} - {desc}")
if verbose:
typer.echo(f" Example: {examples[cmd]}")
typer.echo()

if __name__ == "__main__":
app()
Loading