9 Commits

39 changed files with 823 additions and 783 deletions

View File

@@ -1,13 +0,0 @@
@echo off
setlocal
set "SCRIPT_DIR=%~dp0"
if exist "%SCRIPT_DIR%dcrup.ps1" (
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%dcrup.ps1" %*
exit /b %ERRORLEVEL%
)
if exist "%USERPROFILE%\.dcr\bin\dcrup.ps1" (
powershell -NoProfile -ExecutionPolicy Bypass -File "%USERPROFILE%\.dcr\bin\dcrup.ps1" %*
exit /b %ERRORLEVEL%
)
echo [error] dcrup.ps1 not found near dcrup.cmd >&2
exit /b 1

View File

@@ -1,4 +1,4 @@
#Requires -Version 5.1
#Requires -Version 5.1
$ErrorActionPreference = 'Stop'
$DcrupHome = if ($env:DCRUP_HOME) { $env:DCRUP_HOME } else { Join-Path $env:USERPROFILE '.dcr' }
@@ -6,6 +6,7 @@ $DcrupBin = if ($env:DCRUP_BIN) { $env:DCRUP_BIN } else { Join-Path $DcrupHom
$DcrupTc = Join-Path $DcrupHome 'toolchains'
$DcrupMeta = Join-Path $DcrupHome 'meta'
$RepoUrl = if ($env:DCRUP_REPO) { $env:DCRUP_REPO } else { 'https://github.com/dexoron/dcr' }
$InstallUrl = if ($env:DCRUP_INSTALL_URL) { $env:DCRUP_INSTALL_URL } else { 'https://ps1.dcr-tool.ru' }
$DcrupMirror = if ($env:DCRUP_MIRROR) { $env:DCRUP_MIRROR } else { 'auto' }
$ApiLatest = 'https://api.github.com/repos/dexoron/dcr/releases/latest'
$ApiAll = 'https://api.github.com/repos/dexoron/dcr/releases'
@@ -133,6 +134,18 @@ function Link-Default([string]$id) {
Ok "default → $id ($dst)"
}
function Resolve-InstalledId([string]$spec) {
Parse-Spec $spec
if ($script:SpecChannel -eq 'night' -or $script:SpecFloating) {
$item = Get-ChildItem $DcrupTc -Directory -ErrorAction SilentlyContinue |
Where-Object { $_.Name -like "$($script:SpecChannel)-*" } |
Sort-Object Name | Select-Object -Last 1
if ($item) { return $item.Name }
return $null
}
return (Toolchain-Id)
}
function Set-Mirror([string]$value) {
if ($value -notin @('auto', 'cf', 'gh', 'sf', 'ya')) {
Die "invalid --mirror: $value (use auto|cf|gh|sf|ya)"
@@ -379,7 +392,19 @@ function Cmd-Show {
function Cmd-SelfInstall {
Ensure-Dirs
Copy-Item $PSCommandPath (Join-Path $DcrupBin 'dcrup.ps1') -Force
if ([string]::IsNullOrWhiteSpace($PSCommandPath) -or -not (Test-Path $PSCommandPath)) {
# With `irm URL | iex`, PowerShell evaluates text and there is no
# source path. Download the canonical installer for self-install.
$tmp = Join-Path $env:TEMP ("dcrup-" + [guid]::NewGuid().ToString('N') + '.ps1')
try {
Invoke-WebRequest -Uri $InstallUrl -OutFile $tmp -UseBasicParsing -UserAgent 'dcrup'
Copy-Item $tmp (Join-Path $DcrupBin 'dcrup.ps1') -Force
} finally {
Remove-Item $tmp -Force -ErrorAction SilentlyContinue
}
} else {
Copy-Item $PSCommandPath (Join-Path $DcrupBin 'dcrup.ps1') -Force
}
Install-CmdShim
Ensure-UserPath
Ok "dcrup installed to $DcrupBin (use: dcrup …)"
@@ -417,7 +442,7 @@ switch ($cmd) {
if ($a -like 'night-*') { Cmd-Install @('night', '--build', '--force') }
elseif ($a -like 'stable-*') { Cmd-Install @('stable', '--force') }
elseif ($a -like 'dev-*') { Cmd-Install @('dev', '--force') }
else { Ok "pinned $a — install a newer version explicitly" }
else { Ok "pinned $a - install a newer version explicitly" }
}
'uninstall' {
if ($rest -contains '--all') {
@@ -426,9 +451,21 @@ switch ($cmd) {
Remove-Item (Active-Path) -ErrorAction SilentlyContinue
Ok 'removed all'
} else {
Die 'use: dcrup uninstall --all (or install a replacement first)'
if ($rest.Count -ne 1) { Die 'usage: dcrup uninstall <spec>|--all' }
$id = Resolve-InstalledId $rest[0]
if (-not $id) { Die "not installed: $($rest[0])" }
$dir = Join-Path $DcrupTc $id
if (-not (Test-Path $dir)) { Die "not installed: $($rest[0])" }
Remove-Item -Recurse -Force $dir
if ((Read-Active) -eq $id) {
Remove-Item (Join-Path $DcrupBin 'dcr.exe') -ErrorAction SilentlyContinue
Remove-Item (Active-Path) -ErrorAction SilentlyContinue
Warn 'removed active toolchain; install or select another default'
}
Ok "removed $id"
}
}
'self-install' { Cmd-SelfInstall }
default { Die "unknown command: $cmd" }
}

996
dcrup.sh Executable file → Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ Install and switch DCR versions (stable / dev / night, pin `0.8.2`, optional bui
### Linux / macOS / BSD / Windows (bash)
```sh
curl -fsSL https://sh.dcr-tool.ru | sh -s -- self-install
curl --proto '=https' --tlsv1.2 -sSf https://sh.dcr-tool.ru | sh -s -- self-install
export PATH="$HOME/.dcr/bin:$PATH"
dcrup install stable
```
@@ -19,28 +19,19 @@ dcrup install stable
Non-interactive install of DCR in one shot:
```sh
curl -fsSL https://sh.dcr-tool.ru | sh -s -- install stable
curl --proto '=https' --tlsv1.2 -sSf https://sh.dcr-tool.ru | sh -s -- install stable
export PATH="$HOME/.dcr/bin:$PATH"
```
### Windows (PowerShell)
```powershell
irm https://ps1.dcr-tool.ru | iex
# or download then run:
# irm https://ps1.dcr-tool.ru -OutFile dcrup.ps1
# powershell -File .\dcrup.ps1 self-install
& ([scriptblock]::Create((irm https://ps1.dcr-tool.ru))) self-install
# $env:Path += ";$env:USERPROFILE\.dcr\bin"
dcrup install stable
```
Optional cmd bootstrap (if you prefer `curl` of the cmd shim):
```bat
curl -fsSL -o dcrup.cmd https://cmd.dcr-tool.ru
```
After `self-install`, the command is **`dcrup`** (no `.sh` / `.ps1`): shims live in `~/.dcr/bin` (Unix) or `%USERPROFILE%\.dcr\bin` (Windows `dcrup.cmd`).
After `self-install`, the command is **`dcrup`** (no `.sh` / `.ps1`) and is installed in `~/.dcr/bin` (Unix) or `%USERPROFILE%\.dcr\bin` (Windows).
### Common dcrup commands
@@ -58,6 +49,8 @@ dcrup update
dcrup list
dcrup show
dcrup which
dcrup uninstall 0.8.2 # remove one installed version
dcrup uninstall --all # remove all installed versions
```
Layout: `~/.dcr/toolchains/<id>/dcr` and `~/.dcr/bin/dcr` → active version.

View File

@@ -17,12 +17,11 @@
use crate::prelude::*;
use crate::core::build_config::Config;
use crate::core::deps::register;
use crate::core::{build_config::Config, deps::register};
use crate::utils::cli_styles::{Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SUCCESS_ST};
use crate::utils::fs::find_project_root;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use toml::Value;
use toml::map::Map;
use crate::utils::log::sprintln;
use toml::{Value, map::Map};
/// Parsed arguments for the `dcr add` command.
///
@@ -60,16 +59,16 @@ pub struct AddArgs {
/// Process exit code: `0` on success, non-zero on usage or I/O errors.
pub fn add(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(
" dcr add <name> <source> [--branch <b>] [--tag <t>] [--rev <r>]",
BOLD_CYAN,
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(
HELP_EXAMPLES_ST,
" dcr add <name> <source> [--branch <b>] [--tag <t>] [--rev <r>]"
);
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Adds a dependency to the project.");
println!();
printc("SOURCES:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "SOURCES:");
println!(" github:user/repo GitHub repository");
println!(" gitlab:user/repo GitLab repository");
println!(" git:host.com/user/repo Generic git repository");
@@ -77,7 +76,7 @@ pub fn add(args: &[String]) -> i32 {
println!(" pkg-config:fmt System pkg-config dependency");
println!(" <version> Version from registry");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --branch <b> Use a specific branch");
println!(" --tag <t> Use a specific tag");
println!(" --rev <r> Use a specific commit hash");
@@ -167,7 +166,7 @@ pub fn add(args: &[String]) -> i32 {
println!(
" {} dependency `{}` to dcr.toml",
colored("Added", BOLD_GREEN),
"Added".style(SUCCESS_ST),
add_args.name
);
0

View File

@@ -28,8 +28,11 @@ use crate::utils::build::{
get_config_opt, get_config_str, get_language_with_profile_or_default, get_string_with_profile,
normalize_kind, resolve_artifact_target_dir, resolve_compiler,
};
use crate::utils::cli_styles::{
BOLD_CYAN, BOLD_YELLOW, Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SUCCESS_ST, Style,
};
use crate::utils::fs::{canonicalize_path, find_project_root};
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, BOLD_YELLOW, colored, printc};
use crate::utils::log::sprintln;
use std::io::IsTerminal;
use std::path::Path;
use std::sync::{Arc, atomic::AtomicBool};
@@ -37,8 +40,8 @@ use std::sync::{Arc, atomic::AtomicBool};
pub use crate::core::build::get_build_string_with_profile;
/// Formats a left-aligned status verb with the given style for CLI output.
fn status(verb: &str, style: &str) -> String {
colored(&format!("{verb:<9}"), style)
fn status(verb: &str, style: Style) -> String {
format!("{verb:<9}").style(style).to_string()
}
/// CLI build reporter that prints human-readable progress to stderr/stdout.
@@ -51,7 +54,7 @@ impl CliReporter {
/// - `verb`: Short status label (e.g. `"target"`, `"dep"`).
/// - `style`: Color/style constant for the verb.
/// - `rest`: Remaining message text after the verb.
fn line(&self, verb: &str, style: &str, rest: &str) {
fn line(&self, verb: &str, style: Style, rest: &str) {
eprintln!(" {} {}", status(verb, style), rest);
}
}
@@ -95,12 +98,12 @@ impl BuildReporter for CliReporter {
common::finish_progress_line();
// Only announce deps that were actually rebuilt this run.
if rebuilt {
self.line("ready", BOLD_GREEN, &format!("{name} v{version}"));
self.line("ready", SUCCESS_ST, &format!("{name} v{version}"));
}
}
BuildEvent::Compiling { name, version } => {
common::finish_progress_line();
let label = format!(" {} {} v{}", status("compile", BOLD_GREEN), name, version);
let label = format!(" {} {} v{}", status("compile", SUCCESS_ST), name, version);
// Terminals use an in-place progress line; non-TTY gets a plain log line.
common::set_progress_label(Some(label.clone()));
if !std::io::stderr().is_terminal() {
@@ -113,7 +116,7 @@ impl BuildReporter for CliReporter {
}
BuildEvent::Finished { secs } => {
common::finish_progress_line();
self.line("done", BOLD_GREEN, &format!("in {secs}s"));
self.line("done", SUCCESS_ST, &format!("in {secs}s"));
}
BuildEvent::CompilerOutput { stream, text } => {
// Pause the progress spinner so compiler text is not overwritten.
@@ -141,16 +144,16 @@ impl BuildReporter for CliReporter {
/// Process exit code: `0` on success or help, non-zero on failure.
pub fn build(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(
" dcr build [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose] [--print-artifact-path]",
BOLD_CYAN,
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(
HELP_EXAMPLES_ST,
" dcr build [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose] [--print-artifact-path]"
);
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Compiles the project. Default profile is --debug.");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --debug Build with debug profile (default)");
println!(" --release Build with release profile");
println!(" --target <triple> Cross-compile for the given target");

View File

@@ -20,11 +20,13 @@ use crate::prelude::*;
use crate::core::build_config::Config;
use crate::core::workspace::parse_workspace;
use crate::utils::build::{default_profile_flags, default_target_triple, parse_version_info};
use crate::utils::cli_styles::{
BOLD_GREEN, Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SUCCESS_ST,
};
use crate::utils::fs::{check_dir, find_project_root, with_dir};
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use crate::utils::log::sprintln;
use glob::glob;
use std::fs;
use std::path::Path;
use std::{fs, path::Path};
/// Entry point for the `dcr clean` command.
///
@@ -37,16 +39,16 @@ use std::path::Path;
/// Process exit code: `0` on success, `1` on failure.
pub fn clean(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(
" dcr clean [--debug | --release] [--target <triple>] [--all]",
BOLD_CYAN,
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(
HELP_EXAMPLES_ST,
" dcr clean [--debug | --release] [--target <triple>] [--all]"
);
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Removes build artifacts from the target directory.");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --debug Clean debug artifacts (default)");
println!(" --release Clean release artifacts");
println!(" --target <triple> Clean artifacts for a specific target");
@@ -211,10 +213,7 @@ fn clean_project_at(
if !items.contains(&"dcr.toml".to_string()) {
return Err("dcr.toml file not found".to_string());
}
println!(
" Cleaning project `{}`",
colored(&project_name, BOLD_GREEN)
);
println!(" Cleaning project `{}`", project_name.style(BOLD_GREEN));
if let Some(profile) = profile {
let target_dir = if let Some(t) = target {
format!("target/{t}/{profile}")
@@ -232,14 +231,14 @@ fn clean_project_at(
if !dir_exists {
warn!("Directory target/{target_dir} not found");
} else {
println!(" Profile: {}", colored(profile, BOLD_GREEN));
println!(" Profile: {}", profile.style(BOLD_GREEN));
if let Some(t) = target {
println!(" Target: {}", colored(t, BOLD_GREEN));
println!(" Target: {}", t.style(BOLD_GREEN));
}
let _ = fs::remove_dir_all(&target_dir);
println!(
"{} Removed directory {}",
colored("\n ✔", BOLD_GREEN),
"\n ✔".style(SUCCESS_ST),
target_dir
);
}
@@ -249,10 +248,7 @@ fn clean_project_at(
if items.contains(&"target".to_string()) {
let _ = fs::remove_dir_all("target");
println!(
"{} Removed directory target",
colored("\n ✔", BOLD_GREEN)
);
println!("{} Removed directory target", "\n ✔".style(SUCCESS_ST));
} else {
warn!("Directory target not found");
}

View File

@@ -17,7 +17,8 @@
use crate::prelude::*;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
use crate::utils::cli_styles::{HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST};
use crate::utils::log::sprintln;
use serde::Deserialize;
use std::fs;
use std::io::Read;
@@ -56,10 +57,10 @@ struct ReleaseAsset {
/// `0` on success / already up to date / pacman-managed refuse; `1` on error.
pub fn flag_update(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(" dcr --update", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr --update");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Updates DCR to the latest version from GitHub Releases.");
return 0;
}

View File

@@ -17,7 +17,10 @@
use crate::prelude::*;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use crate::utils::cli_styles::{
BOLD_GREEN, Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SUCCESS_ST,
};
use crate::utils::log::sprintln;
use glob::glob;
use std::process::Command;
@@ -29,10 +32,10 @@ use std::process::Command;
/// If the first argument is `--help`, prints usage information and returns 0.
pub fn fmt(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(" dcr fmt", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr fmt");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Formats all C/C++ source files using clang-format.");
println!(" Scans src/ and tests/ directories recursively.");
return 0;
@@ -70,14 +73,14 @@ pub fn fmt(args: &[String]) -> i32 {
}
if files.is_empty() {
println!(" {} No files to format", colored("Format", BOLD_GREEN));
println!(" {} No files to format", "Format".style(BOLD_GREEN));
return 0;
}
// Format the collected files
println!(
" {} {} files",
colored("Formatting", BOLD_GREEN),
"Formatting".style(BOLD_GREEN),
files.len()
);
@@ -85,7 +88,7 @@ pub fn fmt(args: &[String]) -> i32 {
match status {
Ok(s) if s.success() => {
println!(" {} successful", colored("Format", BOLD_GREEN));
println!(" {} successful", "Format".style(SUCCESS_ST));
0
}
Ok(s) => {

View File

@@ -28,10 +28,11 @@ use crate::utils::build::{
get_list_with_profile, get_string_with_profile, normalize_kind, normalize_platform,
resolve_artifact_target_dir, resolve_compiler, resolve_pkg_config_flags_lossy,
};
use crate::utils::cli_styles::{HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST};
use crate::utils::fs::{
absolute_join, atomic_write, canonicalize_path, ensure_dcr_dir, find_project_root,
};
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
use crate::utils::log::sprintln;
use std::path::{Path, PathBuf};
use std::time::{SystemTime, UNIX_EPOCH};
@@ -252,29 +253,29 @@ pub struct ProjectInfo {
pub fn r#gen(args: &[String]) -> i32 {
let subcommand = match args.first() {
Some(s) if s == "--help" => {
printc("USAGE:", BOLD_GREEN);
printc(" dcr gen <subcommand>", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr gen <subcommand>");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Generates IDE and tooling integration files.");
println!();
printc("SUBCOMMANDS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "SUBCOMMANDS:");
println!(" project-info Print project metadata as JSON");
println!(" compile-commands Generate .dcr/compile_commands.json");
println!(" vscode Generate .vscode/ integration files");
println!(" clion Generate .idea/ integration files");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --debug | --release Profile (default: debug)");
println!(" --quiet | -q Suppress success messages on stdout");
return 0;
}
Some(s) => s.as_str(),
None => {
printc("USAGE:", BOLD_GREEN);
printc(" dcr gen <subcommand>", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr gen <subcommand>");
println!();
printc("SUBCOMMANDS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "SUBCOMMANDS:");
println!(" project-info Print project metadata as JSON");
println!(" compile-commands Generate .dcr/compile_commands.json");
println!(" vscode Generate .vscode/ integration files");

View File

@@ -15,7 +15,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
use crate::utils::cli_styles::{HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST};
use crate::utils::log::sprintln;
/// Displays the help information for the DCR CLI tool.
///
@@ -27,10 +28,10 @@ pub fn help() -> i32 {
println!("DCR (Dexoron Cargo Realization)");
println!("C project manager inspired by Cargo.");
println!();
printc("USAGE:", BOLD_GREEN);
printc(" dcr <command> [options]", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr <command> [options]");
println!();
printc("COMMANDS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "COMMANDS:");
println!(" new <name> Create a new project");
println!(" init Initialize the current directory as a project");
println!(" build [--profile] Build the project (default: --debug)");
@@ -43,24 +44,24 @@ pub fn help() -> i32 {
println!(" setup Show configured package registries");
println!(" clean Remove the target directory");
println!(" gen <subcommand> Generate IDE integration files");
printc("FLAGS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "FLAGS:");
println!(" --help Show command help");
println!(" --update Update dcr to the latest version");
println!(" --version Show dcr version");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --debug Use debug profile");
println!(" --release Use release profile");
println!(" --force Force rebuild (build/run)");
println!(" --clean Clean before build (build/run)");
println!(" --all Clean all workspace members (clean)");
println!();
printc("EXAMPLES:", BOLD_GREEN);
printc(" dcr new hello", BOLD_CYAN);
printc(" dcr build --release", BOLD_CYAN);
printc(" dcr run --debug", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "EXAMPLES:");
sprintln!(HELP_EXAMPLES_ST, " dcr new hello");
sprintln!(HELP_EXAMPLES_ST, " dcr build --release");
sprintln!(HELP_EXAMPLES_ST, " dcr run --debug");
println!();
printc("TIP:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "TIP:");
println!(" Run 'dcr <command> --help' for command-specific help.");
0
}

View File

@@ -20,10 +20,12 @@ use crate::prelude::*;
use crate::config::FILE_MAIN_C;
use crate::core::build_config::{Config, validate_package_name};
use crate::core::vcs::VcsKind;
use crate::utils::cli_styles::{
BOLD_CYAN, BOLD_GREEN, Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SUCCESS_ST,
};
use crate::utils::fs::check_dir;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use std::fs;
use std::io::Write;
use crate::utils::log::sprintln;
use std::{fs, io::Write};
/// Initializes the current working directory as a new DCR project.
///
@@ -31,10 +33,10 @@ use std::io::Write;
/// `dcr.toml` and `src/main.c`, and configures version control (Git) integration if applicable.
pub fn init(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(" dcr init [--vcs <git|none>]", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr init [--vcs <git|none>]");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Initializes the current directory as a DCR project.");
println!(" The directory must be empty.");
return 0;
@@ -79,7 +81,7 @@ pub fn init(args: &[String]) -> i32 {
if let Err(e) = validate_package_name(&project_name) {
error!(
"Invalid project name `{}`: {e}",
colored(&project_name, BOLD_CYAN),
project_name.style(BOLD_CYAN),
);
return 1;
}
@@ -96,8 +98,8 @@ pub fn init(args: &[String]) -> i32 {
}
println!(
" {} Created file {}",
colored("✔", BOLD_GREEN),
colored("dcr.toml", BOLD_CYAN)
"✔".style(SUCCESS_ST),
"dcr.toml".style(BOLD_CYAN)
);
// Create src directory and write template main.c file.
@@ -118,8 +120,8 @@ pub fn init(args: &[String]) -> i32 {
}
println!(
" {} Created file {}",
colored("✔", BOLD_GREEN),
colored("src/main.c", BOLD_CYAN)
"✔".style(SUCCESS_ST),
"src/main.c".style(BOLD_CYAN)
);
// Resolve target VCS provider or detect existing repositories.
@@ -144,10 +146,7 @@ pub fn init(args: &[String]) -> i32 {
if let Err(e) = crate::core::vcs::init_vcs(vcs_kind, project_path) {
warn!("Failed to initialize git repository: {e}");
} else {
println!(
" {} Initialized git repository",
colored("✔", BOLD_GREEN)
);
println!(" {} Initialized git repository", "✔".style(SUCCESS_ST));
}
} else {
warn!(
@@ -162,9 +161,9 @@ pub fn init(args: &[String]) -> i32 {
println!(
"Project `{}` successfully created\n",
colored(project_name.as_str(), BOLD_GREEN)
project_name.style(SUCCESS_ST)
);
printc("Next step:", BOLD_GREEN);
printc(" dcr run", BOLD_CYAN);
sprintln!(BOLD_GREEN, "Next step:");
sprintln!(BOLD_CYAN, " dcr run");
0
}

View File

@@ -20,8 +20,11 @@ use crate::prelude::*;
use crate::core::build::common;
use crate::core::build_config::Config;
use crate::utils::build::{get_bool_with_profile, get_list_with_profile};
use crate::utils::cli_styles::{
ALERT_ST, BOLD_GREEN, Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SUCCESS_ST,
};
use crate::utils::fs::find_project_root;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, BOLD_YELLOW, colored, printc};
use crate::utils::log::sprintln;
use std::path::{Path, PathBuf};
use std::process::Command;
@@ -30,14 +33,14 @@ use std::process::Command;
/// Scans source roots (configurable via build.roots) and tests/ directory.
pub fn lint(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(" dcr lint [--fix]", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr lint [--fix]");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Runs clang-tidy on all C/C++ source files.");
println!(" Scans source roots (configurable via build.roots) and tests/ directory.");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --fix Apply clang-tidy suggestions automatically");
return 0;
}
@@ -117,13 +120,13 @@ pub fn lint(args: &[String]) -> i32 {
files.sort();
if files.is_empty() {
println!(" {} No files to lint", colored("Lint", BOLD_GREEN));
println!(" {} No files to lint", "Lint".style(BOLD_GREEN));
return 0;
}
println!(
" {} {} files {}",
colored("Linting", BOLD_GREEN),
"Linting".style(BOLD_GREEN),
files.len(),
if do_fix { "(with --fix)" } else { "" }
);
@@ -161,13 +164,13 @@ pub fn lint(args: &[String]) -> i32 {
if issue_count > 0 {
total_issues += issue_count as u32;
failed += 1;
print!(" {} ", colored("×", BOLD_YELLOW));
print!(" {} ", "×".style(ALERT_ST));
println!("{} ({} issues)", file, issue_count);
for issue in &issues {
println!(" {}", issue);
}
} else {
print!(" {} ", colored("✓", BOLD_GREEN));
print!(" {} ", "✓".style(SUCCESS_ST));
println!("{}", file);
}
}
@@ -178,13 +181,13 @@ pub fn lint(args: &[String]) -> i32 {
if failed == 0 {
println!(
" {} {} files, no issues",
colored("Lint", BOLD_GREEN),
"Lint".style(SUCCESS_ST),
total
);
} else {
println!(
" {} {}/{} files passed, {} issues found",
colored("Lint", BOLD_YELLOW),
"Lint".style(ALERT_ST),
passed,
total,
total_issues

View File

@@ -20,10 +20,12 @@ use crate::prelude::*;
use crate::config::FILE_MAIN_C;
use crate::core::build_config::{Config, validate_package_name};
use crate::core::vcs::VcsKind;
use crate::utils::cli_styles::{
BOLD_CYAN, BOLD_GREEN, Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SUCCESS_ST,
};
use crate::utils::fs::check_dir;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use std::fs;
use std::io::Write;
use crate::utils::log::sprintln;
use std::{fs, io::Write};
/// Executes the `dcr new` command to scaffold a new C/C++ project directory structure.
///
@@ -31,10 +33,10 @@ use std::io::Write;
/// template source file generation (`src/main.c`), and initial VCS setup.
pub fn new(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(" dcr new <name> [--vcs <git|none>]", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr new <name> [--vcs <git|none>]");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Creates a new C/C++ project with the given name.");
println!(" The name may only contain ASCII letters, digits, '_' and '-'.");
return 0;
@@ -71,15 +73,12 @@ pub fn new(args: &[String]) -> i32 {
}
let project_name = &clean_args[0];
println!(
"Creating a Project `{}`...",
colored(project_name, BOLD_CYAN)
);
println!("Creating a Project `{}`...", project_name.style(BOLD_CYAN));
if let Err(e) = validate_package_name(project_name) {
error!(
"Invalid project name `{}`: {e}",
colored(project_name, BOLD_CYAN),
project_name.style(BOLD_CYAN),
);
return 1;
}
@@ -87,12 +86,12 @@ pub fn new(args: &[String]) -> i32 {
if items.contains(project_name) {
error!(
"Directory `{}` already exists\n",
colored(project_name, BOLD_CYAN)
project_name.style(BOLD_CYAN)
);
printc("Hint:", BOLD_CYAN);
sprintln!(BOLD_CYAN, "Hint:");
println!(
" Use `{}` to initialize an existing project\n or specify a different project name",
colored("dcr init", BOLD_CYAN)
"dcr init".style(BOLD_CYAN)
);
return 1;
}
@@ -103,7 +102,7 @@ pub fn new(args: &[String]) -> i32 {
}
println!(
" {} Directory created {}",
colored("✔", BOLD_GREEN),
"✔".style(SUCCESS_ST),
project_name
);
@@ -115,8 +114,8 @@ pub fn new(args: &[String]) -> i32 {
}
println!(
" {} Created file {}",
colored("✔", BOLD_GREEN),
colored("dcr.toml", BOLD_CYAN)
"✔".style(SUCCESS_ST),
"dcr.toml".style(BOLD_CYAN)
);
// Generate src directory and populate initial main.c file.
@@ -138,8 +137,8 @@ pub fn new(args: &[String]) -> i32 {
}
println!(
" {} Created file {}",
colored("✔", BOLD_GREEN),
colored("src/main.c", BOLD_CYAN)
"✔".style(SUCCESS_ST),
"src/main.c".style(BOLD_CYAN)
);
// Resolve target VCS mode based on CLI flags or parent directory state.
@@ -165,10 +164,7 @@ pub fn new(args: &[String]) -> i32 {
if let Err(e) = crate::core::vcs::init_vcs(vcs_kind, project_path) {
warn!("Failed to initialize git repository: {e}");
} else {
println!(
" {} Initialized git repository",
colored("✔", BOLD_GREEN)
);
println!(" {} Initialized git repository", "✔".style(SUCCESS_ST));
}
} else {
warn!(
@@ -184,9 +180,9 @@ pub fn new(args: &[String]) -> i32 {
println!(
"Project `{}` successfully created\n",
colored(project_name, BOLD_GREEN)
project_name.style(SUCCESS_ST)
);
printc("Next step:", BOLD_GREEN);
printc(&format!(" cd {}\n dcr run", project_name), BOLD_CYAN);
sprintln!(BOLD_GREEN, "Next step:");
sprintln!(BOLD_CYAN, " cd {}\n dcr run", project_name);
0
}

View File

@@ -22,11 +22,10 @@ use crate::cli::flags::parse_build_run_flags;
use crate::core::build_config::Config;
use crate::core::runner::run_binary;
use crate::utils::build::{normalize_target_os, parse_version_info, substitute_vars};
use crate::utils::fs::find_project_root;
use crate::utils::fs::with_dir;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc};
use std::path::Path;
use std::process::Command;
use crate::utils::cli_styles::{BOLD_GREEN, Colorize, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST};
use crate::utils::fs::{find_project_root, with_dir};
use crate::utils::log::sprintln;
use std::{path::Path, process::Command};
/// Retrieves the run command from the config, preferring target-specific,
/// then profile-specific, then the base `run.cmd`.
@@ -68,17 +67,17 @@ fn get_run_cmd(
/// Process exit code from the built binary / `run.cmd`, or non-zero on build/setup failure.
pub fn run(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(
" dcr run [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose] [-- <args>...]",
BOLD_CYAN,
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(
HELP_EXAMPLES_ST,
" dcr run [--debug | --release] [--target <triple>] [--force] [--clean] [--verbose] [-- <args>...]"
);
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Builds and runs the project. Only available for kind = \"bin\".");
println!(" Arguments after `--` are passed to the built binary (cargo-style).");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --debug Run with debug profile (default)");
println!(" --release Run with release profile");
println!(" --target <triple> Cross-compile for the given target");
@@ -129,7 +128,7 @@ pub fn run(args: &[String]) -> i32 {
let display = display_run_cmd(&cmd, &flags.bin_args);
println!(
" {} {}",
colored(&format!("{:<9}", "run"), BOLD_GREEN),
format!("{:<9}", "run").style(BOLD_GREEN),
display
);
return run_shell_with_args(&cmd, &flags.bin_args);
@@ -269,7 +268,7 @@ fn run_project(
let display = display_run_cmd(&cmd, &flags.bin_args);
println!(
" {} {}",
colored(&format!("{:<9}", "run"), BOLD_GREEN),
format!("{:<9}", "run").style(BOLD_GREEN),
display
);
return Ok(run_shell_with_args(&cmd, &flags.bin_args));
@@ -277,7 +276,7 @@ fn run_project(
let display = display_bin_run(&bin_path, &flags.bin_args);
println!(
" {} {}",
colored(&format!("{:<9}", "run"), BOLD_GREEN),
format!("{:<9}", "run").style(BOLD_GREEN),
display
);
return Ok(run_binary(

View File

@@ -15,15 +15,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
use crate::utils::cli_styles::{HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST};
use crate::utils::log::sprintln;
/// Sets up DCR registries by loading the registry manager and printing the list of registries.
pub fn setup(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(" dcr setup", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr setup");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Sets up DCR registries. Downloads and indexes");
println!(" package registries for dependency resolution.");
return 0;

View File

@@ -24,30 +24,35 @@ use crate::utils::build::{
get_config_opt, get_config_str, get_language_with_profile, get_list_with_profile,
get_string_with_profile, resolve_compiler, resolve_pkg_config_flags,
};
use crate::utils::cli_styles::{
BOLD_GREEN, Colorize, ERROR_ST, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST, SKIP_ST, SUCCESS_ST,
Style,
};
use crate::utils::fs::{find_project_root, with_dir};
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, BOLD_RED, RESET, colored, printc};
use crate::utils::log::sprintln;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
const BOLD_BLUE: &str = "\x1b[1m\x1b[94m";
/// Runs project tests and prints a unified testsuite report.
pub fn test(args: &[String]) -> i32 {
let mut init_header = false;
let mut profile = "debug";
for arg in args {
if arg == "--help" {
printc("USAGE:", BOLD_GREEN);
printc(" dcr test [--init] [--debug | --release]", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(
HELP_EXAMPLES_ST,
" dcr test [--init] [--debug | --release]"
);
println!();
printc("ALIASES:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "ALIASES:");
println!(" dcr tests");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Runs project tests and prints a unified testsuite report.");
println!();
printc("OPTIONS:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "OPTIONS:");
println!(" --init Create tests/dcr_test.h in current project");
println!(" --debug Build and run tests with debug profile (default)");
println!(" --release Build and run tests with release profile");
@@ -195,19 +200,19 @@ fn run_testsuite(profile: &str) -> Result<i32, String> {
for line in stdout.lines() {
let line = line.trim();
if let Some(name) = line.strip_prefix("[PASS] ") {
println!("{} {}", colored("[PASS]", BOLD_GREEN), name);
println!("{} {}", "[PASS]".style(SUCCESS_ST), name);
pass += 1;
parsed_any = true;
continue;
}
if let Some(name) = line.strip_prefix("[SKIP] ") {
println!("{} {}", colored("[SKIP]", BOLD_BLUE), name);
println!("{} {}", "[SKIP]".style(SKIP_ST), name);
skip += 1;
parsed_any = true;
continue;
}
if let Some(name) = line.strip_prefix("[FAIL] ") {
println!("{} {}", colored("[FAIL]", BOLD_RED), name);
println!("{} {}", "[FAIL]".style(ERROR_ST), name);
fail += 1;
parsed_any = true;
continue;
@@ -215,17 +220,17 @@ fn run_testsuite(profile: &str) -> Result<i32, String> {
if let Some((status, name)) = line.split_once('\t') {
match status {
"PASS" => {
println!("{} {}", colored("[PASS]", BOLD_GREEN), name);
println!("{} {}", "[PASS]".style(SUCCESS_ST), name);
pass += 1;
parsed_any = true;
}
"SKIP" => {
println!("{} {}", colored("[SKIP]", BOLD_BLUE), name);
println!("{} {}", "[SKIP]".style(SKIP_ST), name);
skip += 1;
parsed_any = true;
}
"FAIL" => {
println!("{} {}", colored("[FAIL]", BOLD_RED), name);
println!("{} {}", "[FAIL]".style(ERROR_ST), name);
fail += 1;
parsed_any = true;
}
@@ -237,11 +242,11 @@ fn run_testsuite(profile: &str) -> Result<i32, String> {
if !parsed_any {
if suite_success {
for name in &declared {
println!("{} {}", colored("[PASS]", BOLD_GREEN), name);
println!("{} {}", "[PASS]".style(SUCCESS_ST), name);
}
pass = declared.len() as i32;
} else {
println!("{} testsuite", colored("[FAIL]", BOLD_RED));
println!("{} testsuite", "[FAIL]".style(ERROR_ST));
fail = 1;
}
}
@@ -253,14 +258,15 @@ fn run_testsuite(profile: &str) -> Result<i32, String> {
};
println!();
println!("{}", colored("=====================", BOLD_GREEN));
println!("{}", colored(" Testsuite summary ", BOLD_GREEN));
println!("{}", colored("=====================", BOLD_GREEN));
sprintln!(BOLD_GREEN, "=====================");
sprintln!(BOLD_GREEN, " Testsuite summary ");
sprintln!(BOLD_GREEN, "=====================");
println!("TOTAL: {}", total);
print_field("PASS", pass, BOLD_GREEN);
print_field("SKIP", skip, BOLD_BLUE);
print_field("FAIL", fail, BOLD_RED);
println!("{}", colored("=====================", BOLD_GREEN));
print_field("PASS", pass, SUCCESS_ST);
print_field("SKIP", skip, SKIP_ST);
print_field("FAIL", fail, ERROR_ST);
sprintln!(BOLD_GREEN, "=====================");
sprintln!(BOLD_GREEN, "=====================");
if fail > 0 || !suite_success {
return Ok(1);
@@ -395,10 +401,10 @@ fn extract_test_names_path(path: &Path) -> Vec<String> {
}
/// Prints a test result field with color coding.
fn print_field(label: &str, value: i32, color: &str) {
fn print_field(label: &str, value: i32, style: Style) {
if value == 0 {
println!("{}: {}", label, value);
} else {
println!("{}{}: {}{}", color, label, value, RESET);
sprintln!(style, "{}: {}", label, value);
}
}

View File

@@ -18,7 +18,8 @@
use crate::prelude::*;
use crate::core::build_config::Config;
use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc};
use crate::utils::cli_styles::{BOLD_CYAN, HELP_EXAMPLES_ST, HELP_SECTION_TITLE_ST};
use crate::utils::log::sprintln;
use std::collections::HashSet;
use std::path::{Path, PathBuf};
use toml::Value;
@@ -29,10 +30,10 @@ use toml::Value;
/// Otherwise, it parses the dcr.toml configuration and prints the dependency tree.
pub fn tree(args: &[String]) -> i32 {
if args.first().is_some_and(|a| a == "--help") {
printc("USAGE:", BOLD_GREEN);
printc(" dcr tree", BOLD_CYAN);
sprintln!(HELP_SECTION_TITLE_ST, "USAGE:");
sprintln!(HELP_EXAMPLES_ST, " dcr tree");
println!();
printc("DESCRIPTION:", BOLD_GREEN);
sprintln!(HELP_SECTION_TITLE_ST, "DESCRIPTION:");
println!(" Displays the dependency tree of the current project.");
return 0;
}
@@ -55,7 +56,7 @@ pub fn tree(args: &[String]) -> i32 {
.and_then(|v| v.as_str())
.unwrap_or("0.0.0");
printc(&format!("{} v{}", name, version), BOLD_CYAN);
sprintln!(BOLD_CYAN, "{} v{}", name, version);
let mut seen = HashSet::new();
seen.insert(name.to_string());

View File

@@ -15,8 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::build::{builder::BuildContext, common};
use crate::platform;
use crate::utils::build::is_bare_metal_target;
use std::path::{Path, PathBuf};

View File

@@ -15,9 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::core::build::builder::BuildContext;
use crate::core::build::builder::artifact;
use crate::core::build::common;
use crate::core::build::{builder::BuildContext, builder::artifact, common};
use crate::utils::build::{is_bare_metal_target, is_compile_only, is_flat_bin};
use std::fs;
use std::path::{Path, PathBuf};

View File

@@ -20,15 +20,10 @@
/// This module provides the MSVC-specific build implementation for C and C++
/// projects, including object compilation and linking for executables, static
/// libraries, shared libraries, and flat binaries.
use crate::core::build::builder::BuildContext;
use crate::core::build::builder::artifact;
use crate::core::build::common;
use crate::core::build::{builder::BuildContext, builder::artifact, common};
use crate::platform;
use crate::utils::build::{is_compile_only, is_flat_bin};
use std::fs;
use std::path::Path;
use std::process::Command;
use std::time::Instant;
use std::{fs, path::Path, process::Command, time::Instant};
/// Builds the project target using the MSVC compiler.
pub fn build(ctx: &BuildContext) -> Result<f64, String> {

View File

@@ -15,8 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::build::{builder::BuildContext, common};
use sha2::{Digest, Sha256};
use std::fs;
use std::path::{Path, PathBuf};

View File

@@ -1,9 +1,6 @@
use crate::core::build::builder::BuildContext;
use crate::core::build::builder::artifact;
use crate::core::build::common;
use crate::core::build::{builder::BuildContext, builder::artifact, common};
use crate::utils::build::{is_compile_only, is_flat_bin};
use std::path::Path;
use std::time::Instant;
use std::{path::Path, time::Instant};
/// Keeps only assembler-relevant flags from a cflags list.
///

View File

@@ -1,9 +1,6 @@
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::build::language::asm::common as asm;
use std::fs;
use std::path::Path;
use std::process::Command;
use crate::core::build::{builder::BuildContext, common};
use std::{fs, path::Path, process::Command};
/// Builds an assembly file using the FASM assembler.
///

View File

@@ -15,12 +15,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::build::language::asm::common as asm;
use std::fs;
use std::path::Path;
use std::process::Command;
use crate::core::build::{builder::BuildContext, common};
use std::{fs, path::Path, process::Command};
/// Builds GAS (`.s`) sources via the GNU Assembler.
///

View File

@@ -1,9 +1,6 @@
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::build::language::asm::common as asm;
use std::fs;
use std::path::Path;
use std::process::Command;
use crate::core::build::{builder::BuildContext, common};
use std::{fs, path::Path, process::Command};
/// Builds MASM (`.asm`) sources via `ml`.
///

View File

@@ -16,12 +16,9 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/// Support for NASM assembly language in the DCR build system.
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::build::language::asm::common as asm;
use std::fs;
use std::path::Path;
use std::process::Command;
use crate::core::build::{builder::BuildContext, common};
use std::{fs, path::Path, process::Command};
/// Builds assembly sources using the NASM assembler.
///

View File

@@ -15,8 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::{build::builder::BuildContext, build::common};
use crate::utils::build::run_pkg_config;
use std::fs;
use std::path::{Path, PathBuf};

View File

@@ -1,10 +1,6 @@
use crate::core::build::builder::BuildContext;
use crate::core::build::common;
use crate::core::build::language::Language;
use crate::core::build::language::asm::common as asm;
use std::fs;
use std::path::Path;
use std::process::Command;
use crate::core::build::{builder::BuildContext, common, language::Language};
use std::{fs, path::Path, process::Command};
/// Represents the LLVM IR language implementation for the build system.
pub struct LlvmIr;

View File

@@ -15,8 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::core::build::engine::ToolchainExecs;
use crate::core::build_config::Config;
use crate::core::{build::engine::ToolchainExecs, build_config::Config};
use crate::utils::build::{VersionInfo, profile_table, substitute_vars};
use glob::glob;
use std::fs;

View File

@@ -21,8 +21,7 @@ use serde::Deserialize;
use std::collections::BTreeMap;
use std::fs;
use std::path::{Path, PathBuf};
use toml::Value;
use toml::map::Map;
use toml::{Value, map::Map};
use toml_edit::{DocumentMut, Item, Table};
const DEFAULT_VERSION: &str = "0.1.0";

View File

@@ -15,8 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use std::fs;
use std::path::Path;
use std::{fs, path::Path};
/// Represents a locked dependency entry containing its name, version, source, and checksum.
#[derive(Debug, Clone)]

View File

@@ -17,9 +17,7 @@
/// Registry configuration management for DCR.
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
use std::{collections::HashMap, fs, path::PathBuf};
/// Represents a registry configuration entry with its URL and priority.
#[derive(Debug, Serialize, Deserialize)]

View File

@@ -16,8 +16,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::platform;
use std::path::Path;
use std::process::Command;
use std::{path::Path, process::Command};
/// Runs the built binary for a project, forwarding `bin_args`.
///

View File

@@ -15,8 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use std::fs;
use std::path::Path;
use std::{fs, path::Path};
/// Initializes a Git repository in the target directory and configures its `.gitignore` file.
///

View File

@@ -15,39 +15,33 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#[allow(dead_code)]
pub const RESET: &str = "\x1b[0m";
pub use owo_colors::{OwoColorize as Colorize, Style};
// Сli theme styles
// Main
#[allow(dead_code)]
pub const BOLD: &str = "\x1b[1m";
pub const BOLD_RED: Style = Style::new().bright_red().bold();
#[allow(dead_code)]
pub const BOLD_GREEN: Style = Style::new().bright_green().bold();
#[allow(dead_code)]
pub const BOLD_YELLOW: Style = Style::new().bright_yellow().bold();
#[allow(dead_code)]
pub const BOLD_CYAN: Style = Style::new().bright_cyan().bold();
#[allow(dead_code)]
pub const BOLD_BLUE: Style = Style::new().bright_blue().bold();
// Help
#[allow(dead_code)]
pub const BRIGHT_RED: &str = "\x1b[91m";
pub const HELP_SECTION_TITLE_ST: Style = BOLD_GREEN;
#[allow(dead_code)]
pub const BRIGHT_GREEN: &str = "\x1b[92m";
#[allow(dead_code)]
pub const BRIGHT_YELLOW: &str = "\x1b[93m";
#[allow(dead_code)]
pub const BRIGHT_CYAN: &str = "\x1b[96m";
#[allow(dead_code)]
pub const BOLD_RED: &str = "\x1b[1m\x1b[91m";
#[allow(dead_code)]
pub const BOLD_GREEN: &str = "\x1b[1m\x1b[92m";
#[allow(dead_code)]
pub const BOLD_YELLOW: &str = "\x1b[1m\x1b[93m";
#[allow(dead_code)]
pub const BOLD_CYAN: &str = "\x1b[1m\x1b[96m";
pub const HELP_EXAMPLES_ST: Style = BOLD_CYAN;
/// Applies ANSI escape codes to format the message with the given style.
///
/// This is a utility for colored output in terminal applications.
// Other
#[allow(dead_code)]
pub fn colored(msg: &str, style: &str) -> String {
format!("{style}{msg}{RESET}")
}
/// Prints `msg` to stdout with the given ANSI `style`.
pub const ERROR_ST: Style = BOLD_RED;
#[allow(dead_code)]
pub fn printc(msg: &str, style: &str) {
println!("{style}{msg}{RESET}");
}
pub const SUCCESS_ST: Style = BOLD_GREEN;
#[allow(dead_code)]
pub const ALERT_ST: Style = BOLD_YELLOW;
#[allow(dead_code)]
pub const SKIP_ST: Style = BOLD_BLUE;

View File

@@ -1,5 +1,4 @@
use std::path::Path;
use std::process::Command;
use std::{path::Path, process::Command};
/// Checks if the `git` executable is available in the system's PATH.
///

View File

@@ -42,3 +42,28 @@ pub fn init() {
})
.init();
}
/// Prints message to stdout with the given `Style`. Copy of println! macro
#[allow(unused_macros)]
macro_rules! sprintln {
($style:expr, $($arg:tt)*) => {
{
use ::owo_colors::OwoColorize as _;
println!("{}", format!($($arg)*).style($style));
}
};
}
/// Prints message to stdout with the given `Style`. Copy of print! macro
#[allow(unused_macros)]
macro_rules! sprint {
($style:expr, $($arg:tt)*) => {
{
use ::owo_colors::OwoColorize as _;
print!("{}", format!($($arg)*).style($style));
}
};
}
#[allow(unused_imports)]
pub(crate) use {sprint, sprintln};

View File

@@ -29,4 +29,4 @@ pub mod git;
pub mod log;
/// Text processing and manipulation helpers.
pub mod text;
pub mod cli_styles;