-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Docs cli update improvement #3173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
HanslettTheDev
wants to merge
14
commits into
pallets:stable
Choose a base branch
from
HanslettTheDev:docs-cli-update-improvement
base: stable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+162
−0
Draft
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
6c894eb
Stable (#3159)
Rowlando13 55966a5
Add Intro to command line turotial
Veebaa 7fe3507
Trigger CI rebuild
Veebaa 7eb012d
Trigger CI rebuild
Veebaa 06967f0
Add command line tutorial to toctree
Veebaa 8d50e71
Trigger Read the Docs rebuild
Veebaa 0905975
Merge remote-tracking branch 'veeba/stable' into docs-cli-update-impr…
HanslettTheDev 634dab4
docs: modified the introduction title and wording. Added 4 extra sect…
HanslettTheDev 1f325bb
docs: modified the title for clarity. The section is about the differ…
HanslettTheDev f72e664
docs(fix): removed some of the extra comments here as somes goes beyo…
HanslettTheDev b99a8a9
docs(fix): added a summary section, quick reference section and a con…
HanslettTheDev f35802c
docs: added more precise links to cover the topics covered. As well a…
HanslettTheDev bda02c6
docs(rename): renamed the file from intro_to_command_line_tutorial to…
HanslettTheDev 5980c30
docs: fixed all the requested changes with regards to the docs comman…
HanslettTheDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| # Command line basics | ||
|
|
||
| TThis tutorial shows the developer the basics of using the command line. It should take about 20 minutes to complete. | ||
|
|
||
HanslettTheDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ```{contents} | ||
| :depth: 2 | ||
| :local: | ||
| ``` | ||
|
|
||
| ## What is a Command Line Interface (CLI)? | ||
|
|
||
| A Command Line Interface (CLI) is a text-based way to interact with your computer. | ||
| Instead of clicking icons or buttons, you type commands into a terminal. Some examples | ||
| of terminals include: | ||
|
|
||
| - **Bash** (Bourne Again SHell): Common on macOS and Linux systems. | ||
| - **cmd.exe**: The traditional command prompt on Windows. | ||
|
|
||
| ## How does it work? | ||
|
|
||
| Users type commands into a CLI shell (e.g., Bash, cmd), which interprets and executes them: | ||
|
|
||
| **Shell Role:** Acts as an intermediary between the user and the operating system<br> | ||
| **Command Process:** | ||
| The shell parses the command, identifying the action, options, and arguments. It locates the command in the system’s PATH and executes it. The system returns output (e.g., data, error messages) to the CLI. | ||
|
|
||
| ## Prerequisites | ||
HanslettTheDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - A computer with a shell (macOS / Linux / Windows). | ||
| - A text editor you can run from the terminal (nano, vi, notepad, code, etc.). | ||
|
|
||
| ## Interacting with your command line | ||
|
|
||
| Before using the command line, it's helpful to know which operating system and shell you are running. Different systems have slightly different commands; the examples below are grouped by platform so you can copy the commands that match your environment. | ||
|
|
||
| ````{tabs} | ||
| ```{tab} macOS / Linux | ||
| ```bash | ||
| # Show OS/version information | ||
| uname -a | ||
|
|
||
| # Print working directory and list files | ||
| pwd | ||
| ls -la | ||
|
|
||
| # Move around the filesystem | ||
| cd /tmp | ||
| cd ~ | ||
| cd .. | ||
|
|
||
| # Create a directory and an empty file | ||
| mkdir -p myproject | ||
| touch myproject/hello.txt | ||
|
|
||
| # Edit the file (simple editor) | ||
| nano myproject/hello.txt | ||
| # What to put in the file | ||
| # Hello from the command line! | ||
|
|
||
| # Print file contents | ||
| cat myproject/hello.txt | ||
|
|
||
| # Search inside the file | ||
| grep "Hello" myproject/hello.txt | ||
|
|
||
| # Show a CLI's help message (mycli here refers to any command line program e.g git, python, etc.) | ||
| mycli --help | ||
| python -m mycli --help | ||
| ```` | ||
|
|
||
| ```` | ||
|
|
||
| ```{tab} Windows (cmd.exe) | ||
| ```bat | ||
| REM Show OS/version information | ||
| ver | ||
|
|
||
| REM Current directory and list files | ||
| echo %CD% | ||
| dir | ||
|
|
||
| REM Move around | ||
| cd /d C:\Temp | ||
| cd /d %USERPROFILE% | ||
| cd .. | ||
|
|
||
| REM Create directory and file | ||
| mkdir myproject | ||
| type nul > myproject\hello.txt | ||
|
|
||
| REM Edit with notepad | ||
| notepad myproject\hello.txt | ||
|
|
||
| REM Print file contents | ||
| type myproject\hello.txt | ||
|
|
||
| REM Search for Hello (findstr) | ||
| findstr "Hello" myproject\hello.txt | ||
|
|
||
| REM Show help for a CLI (mycli here refers to any command line program e.g git, python, etc.) | ||
| mycli --help | ||
| python -m mycli --help | ||
| ```` | ||
|
|
||
| ``` | ||
|
|
||
| ``` | ||
|
|
||
| ## Short explanations (why these commands matter) | ||
|
|
||
| - Operating system information helps you choose the right commands and troubleshoot issues. | ||
| - Directories (folders) contain files and other directories. Paths can be absolute (start at the filesystem root) or relative (start from your current directory). | ||
| - Moving around with `cd` changes your working directory; many commands operate relative to it. | ||
| - Creating and editing small files is how you try things quickly from the terminal without opening a full IDE. | ||
| - Grep-style searching is essential for finding text in logs, configs, or code. | ||
| - Most CLIs expose `--help` (or `-h`) which documents commands, options, and usage. | ||
|
|
||
HanslettTheDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## Quick reference (cheat sheet) | ||
|
|
||
| macOS / Linux | ||
|
|
||
| ```bash | ||
| pwd # print working directory | ||
| ls -la # list files | ||
| cd <dir> # change directory | ||
| mkdir -p <dir> # make directory | ||
| touch <file> # create empty file | ||
| nano <file> # edit | ||
| cat <file> # print contents | ||
| grep <pat> <f> # search | ||
| mycli --help # CLI help (mycli here refers to any command line program e.g git, python, etc.) | ||
| ``` | ||
|
|
||
| Windows (cmd.exe) | ||
|
|
||
| ```bat | ||
| echo %CD% | ||
| dir | ||
| cd /d <dir> | ||
| mkdir <dir> | ||
| type nul > <file> | ||
| notepad <file> | ||
| type <file> | ||
| findstr <pat> <file> | ||
| mycli --help | ||
| ``` | ||
|
|
||
| ## Conclusion | ||
|
|
||
| Congratulations! You've completed the command line basics tutorial. | ||
| You now have the foundational skills to navigate and interact with your computer using the command line. And you are ready to explore Click-based CLIs and build your own! | ||
|
|
||
| ## Next steps and Further Reading | ||
|
|
||
| These resources will take you deeper: | ||
|
|
||
| - Shell basics tutorial: https://swcarpentry.github.io/shell-novice/ | ||
| - Bash manual: https://www.gnu.org/software/bash/manual/ | ||
| - Grep manual (GNU): https://www.gnu.org/software/grep/manual/grep.html | ||
| - Filesystem hierarchy (Linux): https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard | ||
| - Windows filesystem and paths: https://learn.microsoft.com/windows/win32/fileio/file-paths | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ Tutorials | |
|
|
||
| quickstart | ||
| virtualenv | ||
| command-line-tutorial | ||
|
|
||
| How to Guides | ||
| --------------- | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.