diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 1da396e4b..96ca490e5 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,3 +1,10 @@ +# 0.2.8 + +## Features: + +* User can configure the tool on user levels to set their preferred shell and UI mode. +* Default shell will be retrieved from environment variables in unix-based environments. + # 0.2.7 ## Features: diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 3b04ece1f..5ad830cc8 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -170,7 +170,7 @@ checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cargo-chipmunk" -version = "0.2.7" +version = "0.2.8" dependencies = [ "anyhow", "clap", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d56ddc84d..10e62463d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-chipmunk" -version = "0.2.7" +version = "0.2.8" authors = ["Ammar Abou Zor "] edition = "2021" description = "CLI Tool for chipmunk application development" diff --git a/cli/README.md b/cli/README.md index 0a3b6250d..7abaf429f 100644 --- a/cli/README.md +++ b/cli/README.md @@ -39,6 +39,7 @@ Usage: cargo chipmunk Commands: environment Provides commands for the needed tools for the development [aliases: env] print-dot Prints an overview of targets dependencies in print-dot format for `Graphviz` [aliases: dot] + configuration Provides commands for the configuration of this tool on user level [aliases: config] lint Runs linting & clippy for all or the specified targets build Build all or the specified targets clean Clean all or the specified targets @@ -97,6 +98,38 @@ Options: Print help (see a summary with '-h') ``` +## User Configurations + +Users can configure their preferences for the shell used to run process commands and the default UI mode. The configuration file should be located in the Chipmunk home directory, within the `build_cli` directory, named `config.toml`. + +Configurations can be managed via the CLI using the `config` subcommands. These subcommands allow you to resolve the path to the configuration file and generate default configurations, with an option to write them directly to the file. + +Below is an example of the configuration file with the available settings: + +```toml +# Defines the shell to be used for executing process commands. +# Options: +# - `sh` (Unix-based systems only) +# - `cmd` (Windows only) +# - `bash` +# - `zsh` +# - `fish` +# - `nu-shell` +# - `elvish` +# - `power-shell` +# If not specified, the system will default to: +# - The value of the `SHELL` environment variable on Unix-based systems. +# - `cmd` on Windows. +shell = "sh" + +# Defines the preferred UI mode. +# Options: +# - `bars`: Displays progress bars, showing the current line of the output of each command. +# - `report`: Displays progress bars and prints a summary of all command logs to stdout after all jobs have finished. +# - `print`: Outputs each job's result to stdout once the job finishes. No progress bars are displayed. +# - `immediate`: Outputs logs immediately as they are produced, which may cause overlapping logs for parallel jobs. No progress bars are displayed. +ui_mode = "bars" +``` ## Benchmarks via Build CLI Tool diff --git a/cli/src/shell.rs b/cli/src/shell.rs index 2fce2fb42..f25b2e03a 100644 --- a/cli/src/shell.rs +++ b/cli/src/shell.rs @@ -1,7 +1,7 @@ //! Provides struct representing the shell running by user besides a method to generate //! completion of the CLI sub-commands and arguments for the given shell. -use std::{fmt::Display, io, sync::LazyLock}; +use std::{fmt::Display, io}; use anyhow::Context; use clap::CommandFactory; @@ -47,6 +47,7 @@ impl Display for UserShell { #[cfg(unix)] impl Default for UserShell { fn default() -> Self { + use std::sync::LazyLock; // Try to retrieve the default shell from the environment variable if available, // otherwise use 'sh' static DEFAULT_SHELL: LazyLock = LazyLock::new(|| { @@ -129,7 +130,7 @@ impl UserShell { /// Checks if the shell exist on the system by running it with the version argument. pub fn exist(self) -> bool { - // Default shell is always installed on their respecting operating system and doesn't need + // Default shells are always installed on their respecting operating system and don't need // extra checks avoiding other potential problem because `sh` doesn't have a version // argument. let version_arg = match self {