Skip to content
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

Improve help #451

Merged
merged 3 commits into from
Dec 10, 2022
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
7 changes: 4 additions & 3 deletions dsk/ini/shell.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Command shortcuts
alias p print
alias c copy
alias d delete
alias del delete
alias e edit
alias f find
alias g goto
alias go goto
alias h help
alias l list
alias m move
alias p print
alias q quit
alias r read
alias w write

alias del delete
alias go goto
alias sh shell
alias dsk disk
alias mem memory
Expand Down
43 changes: 25 additions & 18 deletions src/usr/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,36 @@ fn help_unknown(cmd: &str) -> Result<(), ExitCode> {
Err(ExitCode::Failure)
}

fn print_usage(alias: &str, command: &str, usage: &str) {
let csi_col1 = Style::color("LightGreen");
let csi_col2 = Style::color("LightCyan");
let csi_reset = Style::reset();
println!(" {}{}{}{:21}{}{}", csi_col1, alias, csi_col2, command, csi_reset, usage);
}

fn help_summary() -> Result<(), ExitCode> {
let csi_color = Style::color("Yellow");
let csi_reset = Style::reset();

println!("{}Usage:{}", csi_color, csi_reset);
print_usage("", "<dir>", " Change directory");
print_usage("", "<cmd>", " Execute command");
println!();

println!("{}Commands:{}", csi_color, csi_reset);
let cmds = [
("c", "opy <file> <file>", "Copy file from source to destination"),
("d", "elete <file>", "Delete file or empty directory"),
("e", "dit <file>", "Edit existing or new file"),
("g", "oto <dir>", "Go to directory"),
("h", "elp <command>", "Display help about a command"),
("l", "ist <dir>", "List entries in directory"),
("m", "ove <file> <file>", "Move file from source to destination"),
("p", "rint <string>", "Print string to screen"),
("q", "uit", "Quit the shell"),
("r", "ead <file>", "Read file to screen"),
("w", "rite <file>", "Write file or directory"),
];
for (alias, command, usage) in &cmds {
let csi_col1 = Style::color("LightGreen");
let csi_col2 = Style::color("LightCyan");
println!(" {}{}{}{:20}{}{}", csi_col1, alias, csi_col2, command, csi_reset, usage);
}
print_usage("c", "opy <file> <file>", "Copy file from source to destination");
print_usage("d", "elete <file>", "Delete file or empty directory");
print_usage("e", "dit <file>", "Edit existing or new file");
print_usage("f", "ind <str> <path>", "Find pattern in path");
print_usage("h", "elp <cmd>", "Display help about a command");
print_usage("l", "ist <dir>", "List entries in directory");
print_usage("m", "ove <file> <file>", "Move file from source to destination");
print_usage("p", "rint <str>", "Print string to screen");
print_usage("q", "uit", "Quit the console");
print_usage("r", "ead <file>", "Read file to screen");
print_usage("w", "rite <file>", "Write file or directory");
println!();

println!("{}Credits:{}", csi_color, csi_reset);
println!(" Made with <3 in 2019-2022 by Vincent Ollivier <v@vinc.cc>");
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/usr/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn main(args: &[&str]) -> Result<(), ExitCode> {
println!();
println!("{}Installation successful!{}", csi_color, csi_reset);
println!();
println!("Exit console or reboot to apply changes");
println!("Quit the console or reboot to apply changes");
}

Ok(())
Expand Down