Skip to content

Commit

Permalink
Build CLI User Config: README & Version & Changelog
Browse files Browse the repository at this point in the history
* Update README file with configuration section
* Increase tool version & Update Changelog
* Move use statement to fix warning on Windows
  • Loading branch information
AmmarAbouZor committed Oct 23, 2024
1 parent f83201d commit 49722fa
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 unis-based environments.

# 0.2.7

## Features:
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-chipmunk"
version = "0.2.7"
version = "0.2.8"
authors = ["Ammar Abou Zor <[email protected]>"]
edition = "2021"
description = "CLI Tool for chipmunk application development"
Expand Down
33 changes: 33 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Usage: cargo chipmunk <COMMAND>
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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions cli/src/shell.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<UserShell> = LazyLock::new(|| {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 49722fa

Please sign in to comment.