From c27ad43a65ce05df1546937d510a4323b2d53f33 Mon Sep 17 00:00:00 2001 From: Remy <107559570+hrszpuk@users.noreply.github.com> Date: Fri, 23 Sep 2022 14:04:40 +0100 Subject: [PATCH 1/4] .gitignore, cargo.toml, and LICENSE updates .gitignore now has .idea stuff and Rust stuff. cargo.toml now has the colored package for command line colours. the LICENSE has been updated --- .gitignore | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++---- Cargo.lock | 66 ++++++++++++++++++++++++++++++++++++ Cargo.toml | 3 +- LICENSE | 2 +- 4 files changed, 162 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 537b67a..d85e5b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,93 @@ -/target -<<<<<<< HEAD -.idea -======= -/test-package ->>>>>>> develop +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index fdc2317..073bab7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,55 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "colored" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + [[package]] name = "fs_extra" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" + [[package]] name = "proc-macro2" version = "1.0.43" @@ -30,6 +73,7 @@ dependencies = [ name = "rectx" version = "0.1.0" dependencies = [ + "colored", "fs_extra", "serde", "serde_derive", @@ -78,3 +122,25 @@ name = "unicode-ident" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index ee567b4..c12c41d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,5 @@ edition = "2021" serde = "1.0.144" serde_derive = "1.0.144" toml = "0.5.9" -fs_extra = "1.2.0" \ No newline at end of file +fs_extra = "1.2.0" +colored = "2.0.0" \ No newline at end of file diff --git a/LICENSE b/LICENSE index b80fc22..142b942 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 hrszpuk +Copyright (c) 2022 Remy Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 22849a9968c7803d8aa0435b771fe3dbe8307ad6 Mon Sep 17 00:00:00 2001 From: Remy <107559570+hrszpuk@users.noreply.github.com> Date: Fri, 23 Sep 2022 14:15:06 +0100 Subject: [PATCH 2/4] New help menu display Now it looks like: ----------------------------- ReCTx Project Manager v1.0.0 ----------------------------- Usage: rectx [Commands] Help : rectx help : Shows this help message. New : rectx new : Creates a new ReCTx project. Build : rectx build : Builds the current ReCTx project. Run : rectx run : Runs the current ReCTx project. For more information check out the GitHub page: https://github.com/hrszpuk/rectx or join the ReCT Discord server: https://discord.gg/Ymm9xGxWZf --- src/cli.rs | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index e505d87..b416d98 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,5 +1,3 @@ -use std::{fs, io}; -use std::io::{ErrorKind, stdout, Write}; /** Cli module * This module manages the command line interface of rectx! * Features: @@ -7,8 +5,10 @@ use std::io::{ErrorKind, stdout, Write}; * - Displaying help menus * - Recognising commands and calling the correct functions **/ - +use std::{fs, io}; +use std::io::{ErrorKind, stdout, Write}; use std::process::exit; +use colored::Colorize; use crate::manager; use crate::manager::generate_project_directory; @@ -226,22 +226,46 @@ pub fn question(message: String) -> bool { /// Show help menu to the user. /// The help menu contains information on commands and flags, and what they do. pub fn help() { - println!( - "ReCTx :: Help Menu - -Usage: rectx [options] - -Commands: - help -> shows this menu - new [name] -> creates a new project - run -> runs the current project - build -> builds the current project + let title = "ReCTx Project Manager"; + let version = "v1.0.0"; + let mut dashes = String::new(); + for _ in 0..(title.len()+version.len()+2) { + dashes.push('-'); + } + println!("{}\n{} {}\n{}\n{} {}\n\n{}", + dashes, title.bold(), version.green(), + dashes, "Usage:".bold(), + "rectx ".bright_green(), + "[Commands]".bold()); + for (name, example, description) in help_commands() { + println!( + "{}\t {} {}\t {} {}", + name.bold().bright_cyan(), + ":".black(), + example.bold().bright_blue(), + ":".black(), + description.bold().bright_green(), + ) + } -For more information visit the GitHub page: https://github.com/hrszpuk/rectx" - ); + println!("\n{}{}", + "For more information check out the GitHub page: ".bold(), + "https://github.com/hrszpuk/rectx".bright_blue()); + println!("{} {}", + "or join the ReCT Discord server:".bold(), + "https://discord.gg/Ymm9xGxWZf".bright_blue()); exit(0); } +pub fn help_commands() -> Vec<(&'static str, &'static str, &'static str)> { + vec![ + ("Help", "rectx help", "Shows this help message."), + ("New", "rectx new", "Creates a new ReCTx project."), + ("Build", "rectx build", "Builds the current ReCTx project."), + ("Run", "rectx run", "Runs the current ReCTx project.") + ] +} + /// A specific help menu for the "new" command. /// Creating a new project using the new command: usage and explanation. pub fn help_new() { From 7180d8a7f267204ec4381c8d9846690309e2bd4b Mon Sep 17 00:00:00 2001 From: Remy <107559570+hrszpuk@users.noreply.github.com> Date: Sat, 24 Sep 2022 18:28:42 +0100 Subject: [PATCH 3/4] More/better help menus All help menus now have colour. All commands now have their own help menu: rectx help help rectx help run rectx help build rectx help create|new Create is now a valid alias for new. There are now commands to help generate the help menus, this is to reduce duplicate code. --- src/cli.rs | 177 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 135 insertions(+), 42 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index b416d98..fe23338 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -31,8 +31,20 @@ pub fn process_flags(args: std::env::Args) { // Example: "new" -> new_project() if arguments.len() > 0 { match arguments[0].as_str() { - "help" => help(), - "new" => new_project(&arguments), + "help" => { + if arguments.len() > 1 { + match arguments[1].as_str() { + "help" => help(), + "new"|"create" => help_new(), + "build" => help_build(), + "run" => help_run(), + _ => help(), + } + } else { + help(); + } + }, + "new"|"create" => new_project(&arguments), "build" => build_project(false), "run" => build_project(true), _ => help_unknown() @@ -226,18 +238,14 @@ pub fn question(message: String) -> bool { /// Show help menu to the user. /// The help menu contains information on commands and flags, and what they do. pub fn help() { - let title = "ReCTx Project Manager"; - let version = "v1.0.0"; - let mut dashes = String::new(); - for _ in 0..(title.len()+version.len()+2) { - dashes.push('-'); - } - println!("{}\n{} {}\n{}\n{} {}\n\n{}", - dashes, title.bold(), version.green(), - dashes, "Usage:".bold(), - "rectx ".bright_green(), - "[Commands]".bold()); - for (name, example, description) in help_commands() { + println!( + "{}{} {}\n\n{}", + get_help_title(), + "Usage:".bold(), + "rectx ".bright_green(), + "[Commands]".bold() + ); + for (name, example, description) in get_help_commands() { println!( "{}\t {} {}\t {} {}", name.bold().bright_cyan(), @@ -248,48 +256,133 @@ pub fn help() { ) } - println!("\n{}{}", - "For more information check out the GitHub page: ".bold(), - "https://github.com/hrszpuk/rectx".bright_blue()); - println!("{} {}", - "or join the ReCT Discord server:".bold(), - "https://discord.gg/Ymm9xGxWZf".bright_blue()); + print_help_info(); exit(0); } -pub fn help_commands() -> Vec<(&'static str, &'static str, &'static str)> { - vec![ - ("Help", "rectx help", "Shows this help message."), - ("New", "rectx new", "Creates a new ReCTx project."), - ("Build", "rectx build", "Builds the current ReCTx project."), - ("Run", "rectx run", "Runs the current ReCTx project.") - ] -} - /// A specific help menu for the "new" command. /// Creating a new project using the new command: usage and explanation. pub fn help_new() { println!( - "ReCTx :: Help Menu :: \"new\" - -Usage: rectx new project-name + "{}{} {}\n\n{} +The {} command will create a {}. +After calling this command you will be {} about the project such as: +- {} +- {} +- {} + +An alias of {} is {} ({}) which functions the same.", + get_help_title(), + "Usage:".bold(), + "rectx new".bright_green(), + "[Description]".bold(), + "new".bold().underline().cyan(), + "new project in a new directory".bold().underline().magenta(), + "prompted for information".bold().underline().blue(), + "Author".blue().bold(), + "Project name".blue().bold(), + "Licensing options".blue().bold(), + "new".cyan().bold().underline(), + "create".cyan().bold().underline(), + "rectx create".bright_green() + ); + print_help_info() +} -This command will create a new ReCT project with the name provided. -The project will contain: /src/main.rs, README.md, and config.toml! +pub fn help_build() { + println!( + "{}{} {}\n\n{} +The {} command can be used to {} from a ReCT project. +The {} command takes information from the {} (generated by {}), +and uses it to create the executable. + +This means you can specify the {}!", + get_help_title(), + "Usage:".bold(), + "rectx build".bright_green(), + "[Description]".bold(), + "build".cyan().bold().underline(), + "create an executable".blue(), + "build".cyan().bold().underline(), + "config.toml".bold().underline(), + "rectx new".bright_green(), + "compiler, compiler flags, executable name, and more".bold().underline(), + ); +} -For more information visit the GitHub page: https://github.com/hrszpuk/rectx" - ) +pub fn help_run() { + println!( + "{}{} {}\n\n{} +The {} command can be used to {} from a ReCT project. +The {} command takes information from the {} (generated by {}), and uses it to create the executable. + +This means you can specify the {}! + +The major difference between the {} command and the {} command is that the {} command {} for you. +{} the {} command has separate settings from the {} command in the {}.", + get_help_title(), + "Usage:".bold(), + "rectx run".bright_green(), + "[Description]".bold(), + "run".cyan().bold().underline(), + "create an executable".blue(), + "run".cyan().bold().underline(), + "config.toml".bold().underline(), + "rectx new".bright_green(), + "compiler, compiler flags, executable name, and more".bold().underline(), + "run".cyan().bold().underline(), + "build".cyan().bold().underline(), + "run".cyan().bold().underline(), + "executes the executable".bold().underline(), + "IMPORTANT NOTE:".magenta(), + "run".cyan().bold().underline(), + "build".cyan().bold().underline(), + "config.toml".bold().underline(), + ); } pub fn help_unknown() { println!( - "ReCTX :: Help Menu :: Unknown + "{}{} {} +The command you have entered does not exist! +Use {} for information on the commands you can use.", + get_help_title(), + "Usage:".bold(), + "rectx ".bright_green(), + "rectx help".bold().underline().cyan() + ); + print_help_info(); +} -Usage: rectx [options] +// Helper commands for printing help menu +// print_help_info() displays the github page link and rect discord server link +// get_help_commands() returns a vector of each help command +// get_help_title() returns a string of the help menu title -The command you have entered does not seem to exist! -Use \"rectx help\" for more information on the commands you can use. +fn print_help_info() { + println!("\n{}{}", + "For more information check out the GitHub page: ".bold(), + "https://github.com/hrszpuk/rectx".bright_blue()); + println!("{} {}", + "or join the ReCT Discord server:".bold(), + "https://discord.gg/Ymm9xGxWZf".bright_blue()); +} -For more information visit the GitHub page: https://github.com/hrszpuk/rectx" - ) +fn get_help_commands() -> Vec<(&'static str, &'static str, &'static str)> { + vec![ + ("Help", "rectx help", "Shows this help message."), + ("New", "rectx new", "Creates a new ReCTx project."), + ("Build", "rectx build", "Builds the current ReCTx project."), + ("Run", "rectx run", "Runs the current ReCTx project.") + ] +} + +fn get_help_title() -> String { + let title = "ReCTx Project Manager"; + let version = "v1.0.0"; + let mut dashes = String::new(); + for _ in 0..(title.len()+version.len()+2) { + dashes.push('-'); + } + format!("{}\n{} {}\n{}\n", dashes, title.bold(), version.bright_green().bold(), dashes) } \ No newline at end of file From 605b9382d77f2c31a96d7b807dde84e3368a09ec Mon Sep 17 00:00:00 2001 From: Remy <107559570+hrszpuk@users.noreply.github.com> Date: Sat, 24 Sep 2022 18:35:30 +0100 Subject: [PATCH 4/4] Added help module for better code organisation I've added a help module and renamed some public help module functions to better organise code. --- src/cli.rs | 257 +++++++++++++++++++++++++++-------------------------- 1 file changed, 133 insertions(+), 124 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index fe23338..7638d1b 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,7 +8,6 @@ use std::{fs, io}; use std::io::{ErrorKind, stdout, Write}; use std::process::exit; -use colored::Colorize; use crate::manager; use crate::manager::generate_project_directory; @@ -34,24 +33,24 @@ pub fn process_flags(args: std::env::Args) { "help" => { if arguments.len() > 1 { match arguments[1].as_str() { - "help" => help(), - "new"|"create" => help_new(), - "build" => help_build(), - "run" => help_run(), - _ => help(), + "help" => help::help_command(), + "new"|"create" => help::new_command(), + "build" => help::build_command(), + "run" => help::run_command(), + _ => help::help_command(), } } else { - help(); + help::help_command(); } }, "new"|"create" => new_project(&arguments), "build" => build_project(false), "run" => build_project(true), - _ => help_unknown() + _ => help::unknown_command() } } else { // Here we call the help menu if we only encounter "rectx" - help() + help::help_command() } } @@ -139,7 +138,7 @@ pub fn new_project(args: &Vec) { } }; } else { - help_new(); + help::new_command(); } exit(0); } @@ -235,36 +234,40 @@ pub fn question(message: String) -> bool { } } -/// Show help menu to the user. -/// The help menu contains information on commands and flags, and what they do. -pub fn help() { - println!( - "{}{} {}\n\n{}", - get_help_title(), - "Usage:".bold(), - "rectx ".bright_green(), - "[Commands]".bold() - ); - for (name, example, description) in get_help_commands() { +mod help { + use std::process::exit; + use colored::Colorize; + + /// Show help menu to the user. + /// The help menu contains information on commands and flags, and what they do. + pub fn help_command() { println!( - "{}\t {} {}\t {} {}", - name.bold().bright_cyan(), - ":".black(), - example.bold().bright_blue(), - ":".black(), - description.bold().bright_green(), - ) - } + "{}{} {}\n\n{}", + get_help_title(), + "Usage:".bold(), + "rectx ".bright_green(), + "[Commands]".bold() + ); + for (name, example, description) in get_help_commands() { + println!( + "{}\t {} {}\t {} {}", + name.bold().bright_cyan(), + ":".black(), + example.bold().bright_blue(), + ":".black(), + description.bold().bright_green(), + ) + } - print_help_info(); - exit(0); -} + print_help_info(); + exit(0); + } -/// A specific help menu for the "new" command. -/// Creating a new project using the new command: usage and explanation. -pub fn help_new() { - println!( - "{}{} {}\n\n{} + /// A specific help menu for the "new" command. + /// Creating a new project using the new command: usage and explanation. + pub fn new_command() { + println!( + "{}{} {}\n\n{} The {} command will create a {}. After calling this command you will be {} about the project such as: - {} @@ -272,47 +275,51 @@ After calling this command you will be {} about the project such as: - {} An alias of {} is {} ({}) which functions the same.", - get_help_title(), - "Usage:".bold(), - "rectx new".bright_green(), - "[Description]".bold(), - "new".bold().underline().cyan(), - "new project in a new directory".bold().underline().magenta(), - "prompted for information".bold().underline().blue(), - "Author".blue().bold(), - "Project name".blue().bold(), - "Licensing options".blue().bold(), - "new".cyan().bold().underline(), - "create".cyan().bold().underline(), - "rectx create".bright_green() - ); - print_help_info() -} + get_help_title(), + "Usage:".bold(), + "rectx new".bright_green(), + "[Description]".bold(), + "new".bold().underline().cyan(), + "new project in a new directory".bold().underline().magenta(), + "prompted for information".bold().underline().blue(), + "Author".blue().bold(), + "Project name".blue().bold(), + "Licensing options".blue().bold(), + "new".cyan().bold().underline(), + "create".cyan().bold().underline(), + "rectx create".bright_green() + ); + print_help_info() + } -pub fn help_build() { - println!( - "{}{} {}\n\n{} + /// Help menu for the build command (rectx build) + /// command: rectx help build + pub fn build_command() { + println!( + "{}{} {}\n\n{} The {} command can be used to {} from a ReCT project. The {} command takes information from the {} (generated by {}), and uses it to create the executable. This means you can specify the {}!", - get_help_title(), - "Usage:".bold(), - "rectx build".bright_green(), - "[Description]".bold(), - "build".cyan().bold().underline(), - "create an executable".blue(), - "build".cyan().bold().underline(), - "config.toml".bold().underline(), - "rectx new".bright_green(), - "compiler, compiler flags, executable name, and more".bold().underline(), - ); -} + get_help_title(), + "Usage:".bold(), + "rectx build".bright_green(), + "[Description]".bold(), + "build".cyan().bold().underline(), + "create an executable".blue(), + "build".cyan().bold().underline(), + "config.toml".bold().underline(), + "rectx new".bright_green(), + "compiler, compiler flags, executable name, and more".bold().underline(), + ); + } -pub fn help_run() { - println!( - "{}{} {}\n\n{} + /// Help menu for the run command (rectx run) + /// command: rectx help run + pub fn run_command() { + println!( + "{}{} {}\n\n{} The {} command can be used to {} from a ReCT project. The {} command takes information from the {} (generated by {}), and uses it to create the executable. @@ -320,69 +327,71 @@ This means you can specify the {}! The major difference between the {} command and the {} command is that the {} command {} for you. {} the {} command has separate settings from the {} command in the {}.", - get_help_title(), - "Usage:".bold(), - "rectx run".bright_green(), - "[Description]".bold(), - "run".cyan().bold().underline(), - "create an executable".blue(), - "run".cyan().bold().underline(), - "config.toml".bold().underline(), - "rectx new".bright_green(), - "compiler, compiler flags, executable name, and more".bold().underline(), - "run".cyan().bold().underline(), - "build".cyan().bold().underline(), - "run".cyan().bold().underline(), - "executes the executable".bold().underline(), - "IMPORTANT NOTE:".magenta(), - "run".cyan().bold().underline(), - "build".cyan().bold().underline(), - "config.toml".bold().underline(), - ); -} + get_help_title(), + "Usage:".bold(), + "rectx run".bright_green(), + "[Description]".bold(), + "run".cyan().bold().underline(), + "create an executable".blue(), + "run".cyan().bold().underline(), + "config.toml".bold().underline(), + "rectx new".bright_green(), + "compiler, compiler flags, executable name, and more".bold().underline(), + "run".cyan().bold().underline(), + "build".cyan().bold().underline(), + "run".cyan().bold().underline(), + "executes the executable".bold().underline(), + "IMPORTANT NOTE:".magenta(), + "run".cyan().bold().underline(), + "build".cyan().bold().underline(), + "config.toml".bold().underline(), + ); + } -pub fn help_unknown() { - println!( - "{}{} {} + /// Help menu for when the user types an unknown command + pub fn unknown_command() { + println!( + "{}{} {} The command you have entered does not exist! Use {} for information on the commands you can use.", - get_help_title(), - "Usage:".bold(), - "rectx ".bright_green(), - "rectx help".bold().underline().cyan() - ); - print_help_info(); -} + get_help_title(), + "Usage:".bold(), + "rectx ".bright_green(), + "rectx help".bold().underline().cyan() + ); + print_help_info(); + } // Helper commands for printing help menu // print_help_info() displays the github page link and rect discord server link // get_help_commands() returns a vector of each help command // get_help_title() returns a string of the help menu title -fn print_help_info() { - println!("\n{}{}", - "For more information check out the GitHub page: ".bold(), - "https://github.com/hrszpuk/rectx".bright_blue()); - println!("{} {}", - "or join the ReCT Discord server:".bold(), - "https://discord.gg/Ymm9xGxWZf".bright_blue()); -} + fn print_help_info() { + println!("\n{}{}", + "For more information check out the GitHub page: ".bold(), + "https://github.com/hrszpuk/rectx".bright_blue()); + println!("{} {}", + "or join the ReCT Discord server:".bold(), + "https://discord.gg/Ymm9xGxWZf".bright_blue()); + } -fn get_help_commands() -> Vec<(&'static str, &'static str, &'static str)> { - vec![ - ("Help", "rectx help", "Shows this help message."), - ("New", "rectx new", "Creates a new ReCTx project."), - ("Build", "rectx build", "Builds the current ReCTx project."), - ("Run", "rectx run", "Runs the current ReCTx project.") - ] -} + fn get_help_commands() -> Vec<(&'static str, &'static str, &'static str)> { + vec![ + ("Help", "rectx help", "Shows this help message."), + ("New", "rectx new", "Creates a new ReCTx project."), + ("Build", "rectx build", "Builds the current ReCTx project."), + ("Run", "rectx run", "Runs the current ReCTx project.") + ] + } -fn get_help_title() -> String { - let title = "ReCTx Project Manager"; - let version = "v1.0.0"; - let mut dashes = String::new(); - for _ in 0..(title.len()+version.len()+2) { - dashes.push('-'); + fn get_help_title() -> String { + let title = "ReCTx Project Manager"; + let version = "v1.0.0"; + let mut dashes = String::new(); + for _ in 0..(title.len() + version.len() + 2) { + dashes.push('-'); + } + format!("{}\n{} {}\n{}\n", dashes, title.bold(), version.bright_green().bold(), dashes) } - format!("{}\n{} {}\n{}\n", dashes, title.bold(), version.bright_green().bold(), dashes) } \ No newline at end of file