diff --git a/rectx.png b/.github/rectx.png similarity index 100% rename from rectx.png rename to .github/rectx.png 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 diff --git a/README.md b/README.md index b57580b..21ae4f1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- +

:radioactive: A powerful project manager for the ReCT programming language! :radioactive:

diff --git a/src/cli.rs b/src/cli.rs index e505d87..7638d1b 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,7 +5,8 @@ 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 crate::manager; use crate::manager::generate_project_directory; @@ -31,15 +30,27 @@ 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::help_command(), + "new"|"create" => help::new_command(), + "build" => help::build_command(), + "run" => help::run_command(), + _ => help::help_command(), + } + } else { + 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() } } @@ -127,7 +138,7 @@ pub fn new_project(args: &Vec) { } }; } else { - help_new(); + help::new_command(); } exit(0); } @@ -223,49 +234,164 @@ 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 - -For more information visit the GitHub page: https://github.com/hrszpuk/rectx" - ); - exit(0); -} +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!( + "{}{} {}\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(), + ) + } -/// 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\" + print_help_info(); + exit(0); + } -Usage: rectx new project-name + /// 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: +- {} +- {} +- {} + +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! + /// 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(), + ); + } -For more information visit the GitHub page: https://github.com/hrszpuk/rectx" - ) -} + /// 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. + +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 + /// 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(); + } -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 + + 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()); + } -The command you have entered does not seem to exist! -Use \"rectx help\" for more information on the commands you can use. + 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.") + ] + } -For more information visit the GitHub page: https://github.com/hrszpuk/rectx" - ) + 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