From 0597b5ddb2f0eb219e60500fcde870bc773dfe54 Mon Sep 17 00:00:00 2001 From: Dexoron Date: Tue, 2 Jun 2026 19:27:44 +0800 Subject: [PATCH] feat: add --help for all commands, man pages --- .github/workflows/release.yml | 59 +++++++- CHANGELOG.md | 50 +++++++ Cargo.lock | 2 +- Cargo.toml | 28 +++- README.md | 38 +++-- docs/README.mdx | 2 + docs/changelog.mdx | 44 ++++++ docs/commands/project-commands.mdx | 4 +- docs/getting-started/installation.mdx | 17 ++- flake.nix | 4 + install.sh | 12 ++ install_bsd.sh | 12 ++ man/man1/dcr-add.1 | 42 ++++++ man/man1/dcr-build.1 | 37 +++++ man/man1/dcr-clean.1 | 26 ++++ man/man1/dcr-fmt.1 | 10 ++ man/man1/dcr-gen.1 | 23 +++ man/man1/dcr-init.1 | 11 ++ man/man1/dcr-new.1 | 13 ++ man/man1/dcr-run.1 | 35 +++++ man/man1/dcr-setup.1 | 11 ++ man/man1/dcr-test.1 | 24 +++ man/man1/dcr-tree.1 | 11 ++ man/man1/dcr.1 | 204 ++++++++++++++++++++++++++ packaging/aur/dcr/PKGBUILD | 3 + src/cli/add.rs | 24 ++- src/cli/build.rs | 20 ++- src/cli/clean.rs | 17 ++- src/cli/flag_update.rs | 10 ++ src/cli/fmt.rs | 14 +- src/cli/gen.rs | 28 +++- src/cli/init.rs | 10 ++ src/cli/new.rs | 10 ++ src/cli/run.rs | 19 ++- src/cli/setup.rs | 14 +- src/cli/test.rs | 12 +- src/cli/tree.rs | 13 +- 37 files changed, 872 insertions(+), 41 deletions(-) create mode 100644 man/man1/dcr-add.1 create mode 100644 man/man1/dcr-build.1 create mode 100644 man/man1/dcr-clean.1 create mode 100644 man/man1/dcr-fmt.1 create mode 100644 man/man1/dcr-gen.1 create mode 100644 man/man1/dcr-init.1 create mode 100644 man/man1/dcr-new.1 create mode 100644 man/man1/dcr-run.1 create mode 100644 man/man1/dcr-setup.1 create mode 100644 man/man1/dcr-test.1 create mode 100644 man/man1/dcr-tree.1 create mode 100644 man/man1/dcr.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0257d3b..92ee1a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -129,6 +129,36 @@ jobs: body_path: .github/release-notes.md prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} + # ── Man Pages Archive ────────────────────────────────────────────────────── + man-pages: + if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }} + needs: [setup, notes, create-release] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.setup.outputs.tag }} + + - name: Download Release Notes + uses: actions/download-artifact@v4 + with: + name: release-notes + path: .github + + - name: Create Man Pages Archive + run: | + tar czf "dcr-man-pages-${{ needs.setup.outputs.version }}.tar.gz" \ + --transform 's/^man\/man1\//usr\/share\/man\/man1\//' \ + man/man1/*.1 + + - name: Upload Man Pages to Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.setup.outputs.tag }} + files: dcr-man-pages-${{ needs.setup.outputs.version }}.tar.gz + body_path: .github/release-notes.md + prerelease: ${{ needs.setup.outputs.prerelease == 'true' }} + # ── Linux Binaries Matrix ────────────────────────────────────────────────── build-linux: if: ${{ github.event_name == 'push' || github.event.inputs.run_linux == 'true' }} @@ -280,6 +310,7 @@ jobs: cargo build --release mkdir -p packaging/snap/dist/bin cp target/release/dcr packaging/snap/dist/bin/ + cp -r man packaging/snap/dist/man - name: Snapcraft Build Action if: matrix.package_type == 'snap' @@ -321,9 +352,12 @@ jobs: cargo build --release --locked } package() { - cd "\$srcdir/\$pkgname-${PKGVER_ORIG}" + cd "\$srcdir/dcr-${PKGVER_ORIG}" install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr" install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE" + for manpage in man/man1/*.1; do + install -Dm644 "\$manpage" "\$pkgdir/usr/share/man/man1/\$(basename "\$manpage")" + done } PKG docker run --rm \ @@ -613,10 +647,11 @@ jobs: cd "\$srcdir/\$pkgname-${PKGVER_ORIG}" install -Dm755 "target/release/dcr" "\$pkgdir/usr/bin/dcr" install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE" + for manpage in man/man1/*.1; do + install -Dm644 "\$manpage" "\$pkgdir/usr/share/man/man1/\$(basename "\$manpage")" + done } PKG - - cat > packages/aur/dcr/.SRCINFO <> "$GITHUB_OUTPUT" echo "macos_x86=$(download_sha "dcr-x86_64-apple-darwin-${VERSION}")" >> "$GITHUB_OUTPUT" echo "macos_arm=$(download_sha "dcr-aarch64-apple-darwin-${VERSION}")" >> "$GITHUB_OUTPUT" + echo "man_pages=$(download_sha "dcr-man-pages-${VERSION}.tar.gz")" >> "$GITHUB_OUTPUT" - name: Checkout homebrew-dexoron uses: actions/checkout@v4 @@ -1164,6 +1203,18 @@ jobs: bin.install Dir["dcr*"].first => "dcr" end + resource "man-pages" do + url "https://github.com/dexoron/dcr/releases/download/v#{version}/dcr-man-pages-#{version}.tar.gz" + sha256 "${{ steps.sha.outputs.man_pages }}" + end + + def install + bin.install Dir["dcr*"].first => "dcr" + resource("man-pages").stage do + man1.install Dir["usr/share/man/man1/*.1"] + end + end + test do system "#{bin}/dcr", "--version" end diff --git a/CHANGELOG.md b/CHANGELOG.md index c8524ef..a1d7715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,55 @@ # Changelog +## [0.7.1] - 2026-06-02 + +Added: + +- **`--help` for all commands** — `dcr build --help`, `dcr run --help`, `dcr new --help`, + `dcr init --help`, `dcr clean --help`, `dcr add --help`, `dcr fmt --help`, + `dcr setup --help`, `dcr tree --help`, `dcr gen --help`, `dcr --update --help`, + `dcr test --help`. All output uses styled headers (green) and usage lines (cyan). +- **Man pages** — 12 troff man pages in `man/man1/`: `dcr.1`, `dcr-build.1`, + `dcr-run.1`, `dcr-new.1`, `dcr-init.1`, `dcr-clean.1`, `dcr-add.1`, `dcr-test.1`, + `dcr-gen.1`, `dcr-fmt.1`, `dcr-tree.1`, `dcr-setup.1`. Viewable via `man dcr`, + `man dcr-build`, etc. +- **Man page installation in all packaging** — install.sh, install_bsd.sh, AUR PKGBUILD, + Debian (cargo-deb), RPM (cargo-generate-rpm), Nix flake (postInstall), Homebrew + (resource + man1.install), Snap, and GitHub Release (dcr-man-pages-*.tar.gz). +- **`dcr init` and `dcr new` name validation** — project names are validated before + directory or file creation. Only ASCII letters, digits, `_` and `-` are allowed. + Invalid names produce a clear error instead of "Failed to write dcr.toml". +- **`documentation` and `homepage` metadata** — added to `Cargo.toml` for docs.rs + and crate listing. +- **Release profile optimizations** — `opt-level = "z"`, LTO, `codegen-units = 1`, + `panic = "abort"`, `strip = true` for smaller binaries. +- **Linux i686, armv7, riscv64 architecture support** — new target triples in release + workflow and installation scripts. +- **AUR packages** — `dcr-dev` and `dcr-dev-bin` publishing workflow for dev releases. +- **Snap publishing support** — automated Snapcraft publishing in CI. +- **`parse_d_file` rewrite** — now handles CRLF, mixed line endings, and Windows + drive letters more robustly. + +Changed: + +- **`validate_package_name` made public** — now callable from CLI commands directly. +- **`--help` output now coloured** — all commands use `printc` with `BOLD_GREEN`/`BOLD_CYAN` + matching the style of `dcr --help`. +- **`gen.rs` no-args output** — now uses styled output instead of raw `eprintln!`. +- **`tree.rs` and `fmt.rs`** — no longer ignore arguments (`_args` → `args`). +- **`setup.rs`** — no longer ignores arguments (`_args` → `args`). +- **README install instructions** — changed `| bash` to `| sh` for POSIX compatibility. + +Fixed: + +- **`dcr new ` creates directory then fails** — validation now happens + before any file operations. +- **`dcr init` creates dcr.toml then fails on invalid directory name** — same fix. +- **Man pages missing after installation** — now installed via install scripts, + package managers, and Homebrew. +- **Windows drive letter false positive** — in dependency file parsing. +- **CRLF `\r\n` breaks dependency parser** — now handles mixed line endings. +- **Newline after backslash not consumed** — in `parse_d_file` escape handling. + ## [0.7.0] - 2026-06-02 Added: diff --git a/Cargo.lock b/Cargo.lock index 92aee21..91c07d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "dcr" -version = "0.7.0" +version = "0.7.1" dependencies = [ "ctrlc", "git2", diff --git a/Cargo.toml b/Cargo.toml index 156753a..26b2094 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,8 @@ build = "build.rs" description = "DCR is a utility for managing C/C++ projects in a Cargo-like style." license = "GPL-3.0-or-later" repository = "https://github.com/dexoron/dcr" +documentation = "https://dcr.dexoron.su/docs" +homepage = "https://dcr.dexoron.su" [package.metadata.binstall] pkg-fmt = "bin" @@ -21,6 +23,18 @@ section = "devel" priority = "optional" assets = [ ["target/release/dcr", "usr/bin/dcr", "755"], + ["man/man1/dcr.1", "usr/share/man/man1/dcr.1", "644"], + ["man/man1/dcr-add.1", "usr/share/man/man1/dcr-add.1", "644"], + ["man/man1/dcr-build.1", "usr/share/man/man1/dcr-build.1", "644"], + ["man/man1/dcr-clean.1", "usr/share/man/man1/dcr-clean.1", "644"], + ["man/man1/dcr-fmt.1", "usr/share/man/man1/dcr-fmt.1", "644"], + ["man/man1/dcr-gen.1", "usr/share/man/man1/dcr-gen.1", "644"], + ["man/man1/dcr-init.1", "usr/share/man/man1/dcr-init.1", "644"], + ["man/man1/dcr-new.1", "usr/share/man/man1/dcr-new.1", "644"], + ["man/man1/dcr-run.1", "usr/share/man/man1/dcr-run.1", "644"], + ["man/man1/dcr-setup.1", "usr/share/man/man1/dcr-setup.1", "644"], + ["man/man1/dcr-test.1", "usr/share/man/man1/dcr-test.1", "644"], + ["man/man1/dcr-tree.1", "usr/share/man/man1/dcr-tree.1", "644"], ] [package.metadata.generate-rpm] @@ -30,7 +44,19 @@ Cargo-like utility to manage C/C++ projects. """ assets = [ - { source = "target/release/dcr", dest = "/usr/bin/dcr", mode = "755" } + { source = "target/release/dcr", dest = "/usr/bin/dcr", mode = "755" }, + { source = "man/man1/dcr.1", dest = "/usr/share/man/man1/dcr.1", mode = "644" }, + { source = "man/man1/dcr-add.1", dest = "/usr/share/man/man1/dcr-add.1", mode = "644" }, + { source = "man/man1/dcr-build.1", dest = "/usr/share/man/man1/dcr-build.1", mode = "644" }, + { source = "man/man1/dcr-clean.1", dest = "/usr/share/man/man1/dcr-clean.1", mode = "644" }, + { source = "man/man1/dcr-fmt.1", dest = "/usr/share/man/man1/dcr-fmt.1", mode = "644" }, + { source = "man/man1/dcr-gen.1", dest = "/usr/share/man/man1/dcr-gen.1", mode = "644" }, + { source = "man/man1/dcr-init.1", dest = "/usr/share/man/man1/dcr-init.1", mode = "644" }, + { source = "man/man1/dcr-new.1", dest = "/usr/share/man/man1/dcr-new.1", mode = "644" }, + { source = "man/man1/dcr-run.1", dest = "/usr/share/man/man1/dcr-run.1", mode = "644" }, + { source = "man/man1/dcr-setup.1", dest = "/usr/share/man/man1/dcr-setup.1", mode = "644" }, + { source = "man/man1/dcr-test.1", dest = "/usr/share/man/man1/dcr-test.1", mode = "644" }, + { source = "man/man1/dcr-tree.1", dest = "/usr/share/man/man1/dcr-tree.1", mode = "644" }, ] [dependencies] diff --git a/README.md b/README.md index 1d5310c..856ff73 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ [![AUR](https://img.shields.io/aur/version/dcr)](https://aur.archlinux.org/packages/dcr) [![Crates.io](https://img.shields.io/crates/v/dcr)](https://crates.io/crates/dcr) [![Homebrew](https://img.shields.io/badge/homebrew-dexoron%2Fdexoron-orange)](https://github.com/dexoron/homebrew-dexoron) +[![Snap](https://img.shields.io/badge/snap-dcrup-orange)](https://snapcraft.io/dcrup)
[![GitHub Stars](https://img.shields.io/github/stars/dexoron/dcr?style=flat)](https://github.com/dexoron/dcr/stargazers) [![License: GPL-3.0](https://img.shields.io/badge/License-GPL--3.0-blue.svg)](LICENSE) @@ -22,10 +23,11 @@ ## Why DCR? - **No boilerplate** — one config file, predictable structure -- **Cargo-like workflow** — `build`, `run`, `clean`, `test`, `add` +- **Cargo-like workflow** — `build`, `run`, `clean`, `test`, `add`, `fmt` - **Cross-compilation** — full target triple support with short names - **IDE integration** — VS Code, CLion, `compile_commands.json` out of the box - **Dependencies** — path, git, and registry-based with lock file +- **Man pages** — `man dcr` and per-command pages (`man dcr-build`, `man dcr-new`, etc.) --- @@ -119,6 +121,16 @@ curl -fsSL https://dcr.dexoron.su/install.sh | sh curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh ``` + + + +Snap (Linux) + + +```sh +sudo snap install dcrup +``` + @@ -200,24 +212,26 @@ kind = "bin" | `dcr gen ` | Generate IDE integration | | `dcr setup` | Initialize DCR registry | -other in [docs/](docs/) and `dcr --help` +other in [docs/](docs/), `dcr --help` and `dcr --help` --- -## Platforms(pre-build source) +## Platforms (pre-built binary)
-| OS | x86_64 | aarch64 | armv7 | i686 | riscv64 | GNU | Musl | MSVC | MinGW | -|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| -| Linux | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | -| macOS | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | -| Windows | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | -| FreeBSD | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | -| OpenBSD | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | -| NetBSD | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | +| OS | x86_64 | aarch64 | armv7 | i686 | riscv64 | +|:---:|:---:|:---:|:---:|:---:|:---:| +| Linux (GNU) | ✅ | ✅ | ✅ | ✅ | ✅ | +| Linux (Musl) | ✅ | ✅ | ❌ | ❌ | ❌ | +| macOS | ✅ | ✅ | ❌ | ❌ | ❌ | +| Windows (MSVC) | ✅ | ✅ | ❌ | ❌ | ❌ | +| Windows (MinGW) | ✅ | ❌ | ❌ | ❌ | ❌ | +| FreeBSD | ✅ | ❌ | ❌ | ❌ | ❌ | +| OpenBSD | ✅ | ❌ | ❌ | ❌ | ❌ | +| NetBSD | ✅ | ❌ | ❌ | ❌ | ❌ | -✅ officially supported · ⚠️ community / best-effort · ❌ not supported +✅ officially supported · ❌ not supported
diff --git a/docs/README.mdx b/docs/README.mdx index cfa6eb6..a369f83 100644 --- a/docs/README.mdx +++ b/docs/README.mdx @@ -58,3 +58,5 @@ dcr gen vscode - **Registry + Git + Path** — three dependency mechanisms - **IDE generation** — VS Code, CLion, compile_commands.json, JSON metadata - **pkg-config** — automatic system library discovery +- **Per-command `--help`** — `dcr build --help`, `dcr new --help`, etc. +- **Man pages** — `man dcr`, `man dcr-build`, `man dcr-new` diff --git a/docs/changelog.mdx b/docs/changelog.mdx index 36cc191..66b0d74 100644 --- a/docs/changelog.mdx +++ b/docs/changelog.mdx @@ -4,6 +4,50 @@ sidebar_label: Changelog # Changelog +## 0.7.1 (2026-06-02) + +### Added + +- **`--help` for all commands** — `dcr build --help`, `dcr run --help`, `dcr new --help`, + `dcr init --help`, `dcr clean --help`, `dcr add --help`, `dcr fmt --help`, + `dcr setup --help`, `dcr tree --help`, `dcr gen --help`, `dcr --update --help`, + `dcr test --help`. All output uses styled headers (green) and usage lines (cyan). +- **Man pages** — 12 troff pages in `man/man1/`: `dcr.1`, `dcr-build.1`, + `dcr-run.1`, `dcr-new.1`, `dcr-init.1`, `dcr-clean.1`, `dcr-add.1`, `dcr-test.1`, + `dcr-gen.1`, `dcr-fmt.1`, `dcr-tree.1`, `dcr-setup.1`. +- **Man pages in all packaging** — install.sh, install_bsd.sh, AUR PKGBUILD, + Debian (cargo-deb), RPM (cargo-generate-rpm), Nix (postInstall), Homebrew + (resource), Snap, GitHub Release assets. +- **Project name validation** — `dcr init` and `dcr new` now validate names before + creating files. Only ASCII letters, digits, `_` and `-` are allowed. +- **`documentation` and `homepage` fields** — added to `Cargo.toml`. +- **Release profile optimizations** — `opt-level = "z"`, LTO, `codegen-units = 1`, + `panic = "abort"`, `strip = true` for smaller binaries. +- **Linux i686, armv7, riscv64 targets** — added to release workflow and install scripts. +- **Linux musl i686, armv7 targets** — cross-compiled via zigbuild in CI. +- **AUR packages** — `dcr-dev`, `dcr-dev-bin` publishing workflow. +- **Snap publishing** — automated Snapcraft publishing in CI. +- **Snap badge** — in README. + +### Changed + +- **`validate_package_name` made public** — callable from CLI commands. +- **README platform table** — reorganized: libc variants as separate OS rows, + removed extra columns. Linux architecture list updated. +- **`gen.rs` no-args output** — now uses styled output instead of raw `eprintln!`. +- **`tree.rs`, `fmt.rs`, and `setup.rs`** — now accept arguments for `--help`. +- **README install commands** — `| bash` → `| sh` for POSIX compatibility. + +### Fixed + +- **`dcr new ` creates directory then fails** — validation now + happens before any file operations. +- **`dcr init` on invalid directory name** — same fix. +- **Man pages missing in installed packages** — now shipped in all formats. +- **Windows drive letter false positive** — in dependency file parser. +- **CRLF (`\r\n`) breaks dependency parser** — now handles mixed line endings. +- **Newline after backslash not consumed** — in `parse_d_file` escape handling. + ## 0.7.0 (2026-06-01) ### Added diff --git a/docs/commands/project-commands.mdx b/docs/commands/project-commands.mdx index 6a03020..0adacb8 100644 --- a/docs/commands/project-commands.mdx +++ b/docs/commands/project-commands.mdx @@ -8,6 +8,8 @@ sidebar_label: Project commands (new, init) Creates a new project with a standard structure and `dcr.toml`. The `name` argument is required. +Only ASCII letters, digits, underscores `_` and hyphens `-` are allowed in the project name. + ```bash dcr new my-app ``` @@ -25,4 +27,4 @@ mkdir app && cd app dcr init ``` -The project name is taken from the current directory name. +The project name is taken from the current directory name. The directory name must follow the same naming rules as `dcr new`. diff --git a/docs/getting-started/installation.mdx b/docs/getting-started/installation.mdx index f666819..956bf44 100644 --- a/docs/getting-started/installation.mdx +++ b/docs/getting-started/installation.mdx @@ -36,6 +36,12 @@ brew tap dexoron/dexoron brew install dcr ``` +## Snap (Linux) + +```sh +sudo snap install dcrup +``` + ## Nix (flake) ```sh @@ -53,13 +59,13 @@ cargo install dcr ## Linux / macOS (script) ```sh -curl -fsSL https://dcr.dexoron.su/install.sh | bash +curl -fsSL https://dcr.dexoron.su/install.sh | sh ``` ## BSD (script) ```sh -curl -fsSL https://dcr.dexoron.su/install_bsd.sh | bash +curl -fsSL https://dcr.dexoron.su/install_bsd.sh | sh ``` ## Windows (PowerShell) @@ -84,6 +90,13 @@ Verify the installation: dcr --version ``` +Man pages are available after installation: + +```bash +man dcr +man dcr-build +``` + To use the registry, create `~/.dcr/config.toml`: ```toml diff --git a/flake.nix b/flake.nix index 0e24749..41a9891 100644 --- a/flake.nix +++ b/flake.nix @@ -64,6 +64,10 @@ pkgs.darwin.apple_sdk.frameworks.SystemConfiguration ]; + postInstall = '' + install -Dm644 man/man1/*.1 -t $out/share/man/man1/ + ''; + # Tests require external services; run separately. doCheck = false; }; diff --git a/install.sh b/install.sh index bc64f5f..b600c3b 100755 --- a/install.sh +++ b/install.sh @@ -4,6 +4,7 @@ set -Eeuo pipefail TMPDIR="/tmp/dcr-install" INSTALL_PATH="$HOME/.local/share/dcr" BINPATH="$HOME/.local/bin" +MANPATH="${XDG_DATA_HOME:-$HOME/.local/share}/man" LOGFILE="$HOME/.cache/dcr-install.log" REPO_URL="https://github.com/dexoron/dcr" GITHUB_API_LATEST="https://api.github.com/repos/dexoron/dcr/releases/latest" @@ -199,6 +200,16 @@ install_link() { success "Command 'dcr' added to $BINPATH" } +install_man() { + log "Installing man pages..." + local man_src="$TMPDIR/man/man1" + if [[ -d "$man_src" ]]; then + mkdir -p "$MANPATH/man1" + cp "$man_src"/*.1 "$MANPATH/man1/" + success "Man pages installed to $MANPATH/man1" + fi +} + check_path() { if ! echo "$PATH" | grep -q "$BINPATH"; then warn "Directory $BINPATH not found in PATH" @@ -231,6 +242,7 @@ main() { fi install_link + install_man check_path cleanup diff --git a/install_bsd.sh b/install_bsd.sh index 2088d03..e793c9b 100755 --- a/install_bsd.sh +++ b/install_bsd.sh @@ -4,6 +4,7 @@ set -eu TMPDIR="/tmp/dcr-install" INSTALL_PATH="$HOME/.local/share/dcr" BINPATH="$HOME/.local/bin" +MANPATH="${XDG_DATA_HOME:-$HOME/.local/share}/man" LOGFILE="$HOME/.cache/dcr-install.log" REPO_URL="https://github.com/dexoron/dcr" GITHUB_API_LATEST="https://api.github.com/repos/dexoron/dcr/releases/latest" @@ -187,6 +188,16 @@ install_link() { success "Command 'dcr' added to $BINPATH" } +install_man() { + log "Installing man pages..." + man_src="$TMPDIR/man/man1" + if [ -d "$man_src" ]; then + mkdir -p "$MANPATH/man1" + cp "$man_src"/*.1 "$MANPATH/man1/" + success "Man pages installed to $MANPATH/man1" + fi +} + check_path() { if ! echo "$PATH" | grep -q "$BINPATH"; then warn "Directory $BINPATH not found in PATH" @@ -219,6 +230,7 @@ main() { fi install_link + install_man check_path cleanup diff --git a/man/man1/dcr-add.1 b/man/man1/dcr-add.1 new file mode 100644 index 0000000..e3899a2 --- /dev/null +++ b/man/man1/dcr-add.1 @@ -0,0 +1,42 @@ +.TH DCR-ADD 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-add \- Add a dependency to a DCR project +.SH SYNOPSIS +.B dcr add \fI\fR \fI\fR +[\fB\-\-branch\fR \fI\fR] +[\fB\-\-tag\fR \fI\fR] +[\fB\-\-rev\fR \fI\fR] +.SH DESCRIPTION +Adds a dependency to the project. +.SH SOURCES +.TP +.B user/repo +GitHub shorthand. +.TP +.B github:user/repo +Full GitHub repository. +.TP +.B gitlab:user/repo +GitLab repository. +.TP +.B git:host.com/user/repo +Generic git repository. +.TP +.B path:./path/to/lib +Local path dependency. +.TP +.B +Version from registry. +.SH OPTIONS +.TP +.B \-\-branch \fI\fR +Use a specific branch. +.TP +.B \-\-tag \fI\fR +Use a specific tag. +.TP +.B \-\-rev \fI\fR +Use a specific commit hash. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-tree (1) diff --git a/man/man1/dcr-build.1 b/man/man1/dcr-build.1 new file mode 100644 index 0000000..7c80c21 --- /dev/null +++ b/man/man1/dcr-build.1 @@ -0,0 +1,37 @@ +.TH DCR-BUILD 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-build \- Compile a DCR project +.SH SYNOPSIS +.B dcr build +[\fB\-\-debug\fR | \fB\-\-release\fR] +[\fB\-\-target\fR \fI\fR] +[\fB\-\-force\fR] +[\fB\-\-clean\fR] +[\fB\-\-verbose\fR] +[\fB\-\-workspace\fR \fI\fR] +.SH DESCRIPTION +Compiles the project. Default profile is \fB\-\-debug\fR. +.SH OPTIONS +.TP +.B \-\-debug +Build with debug profile (default). Enables debug symbols. +.TP +.B \-\-release +Build with release profile. Enables full optimization. +.TP +.B \-\-target \fI\fR +Cross-compile for the given target. +.TP +.B \-\-force +Force a full rebuild, ignoring cached artifacts. +.TP +.B \-\-clean +Clean before building. +.TP +.B \-\-verbose +Print detailed build output including compiler commands. +.TP +.B \-\-workspace \fI\fR +Build a specific workspace member. +.SH SEE ALSO +.BR dcr (1) diff --git a/man/man1/dcr-clean.1 b/man/man1/dcr-clean.1 new file mode 100644 index 0000000..d375a6e --- /dev/null +++ b/man/man1/dcr-clean.1 @@ -0,0 +1,26 @@ +.TH DCR-CLEAN 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-clean \- Remove build artifacts +.SH SYNOPSIS +.B dcr clean +[\fB\-\-debug\fR | \fB\-\-release\fR] +[\fB\-\-target\fR \fI\fR] +[\fB\-\-all\fR] +.SH DESCRIPTION +Removes build artifacts from the target directory. +.SH OPTIONS +.TP +.B \-\-debug +Clean debug artifacts (default). +.TP +.B \-\-release +Clean release artifacts. +.TP +.B \-\-target \fI\fR +Clean artifacts for a specific target. +.TP +.B \-\-all +Clean all workspace members. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-build (1) diff --git a/man/man1/dcr-fmt.1 b/man/man1/dcr-fmt.1 new file mode 100644 index 0000000..6c8e9ca --- /dev/null +++ b/man/man1/dcr-fmt.1 @@ -0,0 +1,10 @@ +.TH DCR-FMT 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-fmt \- Format C/C++ source files +.SH SYNOPSIS +.B dcr fmt +.SH DESCRIPTION +Formats all C/C++ source files using clang-format. Scans \fBsrc/\fR +and \fBtests/\fR directories recursively. +.SH SEE ALSO +.BR dcr (1) diff --git a/man/man1/dcr-gen.1 b/man/man1/dcr-gen.1 new file mode 100644 index 0000000..5b61487 --- /dev/null +++ b/man/man1/dcr-gen.1 @@ -0,0 +1,23 @@ +.TH DCR-GEN 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-gen \- Generate IDE and tooling integration files +.SH SYNOPSIS +.B dcr gen \fI\fR +.SH DESCRIPTION +Generates IDE and tooling integration files for DCR projects. +.SH SUBCOMMANDS +.TP +.B project-info +Print project metadata as JSON to stdout. +.TP +.B compile-commands +Generate \fBcompile_commands.json\fR for IDE tooling. +.TP +.B vscode +Generate \fB.vscode/\fR integration files (tasks, launch configurations). +.TP +.B clion +Generate \fB.idea/\fR integration files for CLion. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-build (1) diff --git a/man/man1/dcr-init.1 b/man/man1/dcr-init.1 new file mode 100644 index 0000000..62c7368 --- /dev/null +++ b/man/man1/dcr-init.1 @@ -0,0 +1,11 @@ +.TH DCR-INIT 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-init \- Initialize a directory as a DCR project +.SH SYNOPSIS +.B dcr init +.SH DESCRIPTION +Initializes the current directory as a DCR project. The directory must +be empty. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-new (1) diff --git a/man/man1/dcr-new.1 b/man/man1/dcr-new.1 new file mode 100644 index 0000000..1c2d490 --- /dev/null +++ b/man/man1/dcr-new.1 @@ -0,0 +1,13 @@ +.TH DCR-NEW 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-new \- Create a new DCR project +.SH SYNOPSIS +.B dcr new \fI\fR +.SH DESCRIPTION +Creates a new C/C++ project with the given name. The name may only +contain ASCII letters, digits, underscores and hyphens. +.SH EXAMPLE +.B dcr new my-project +.SH SEE ALSO +.BR dcr (1), +.BR dcr-init (1) diff --git a/man/man1/dcr-run.1 b/man/man1/dcr-run.1 new file mode 100644 index 0000000..c5939b3 --- /dev/null +++ b/man/man1/dcr-run.1 @@ -0,0 +1,35 @@ +.TH DCR-RUN 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-run \- Build and run a DCR project +.SH SYNOPSIS +.B dcr run +[\fB\-\-debug\fR | \fB\-\-release\fR] +[\fB\-\-target\fR \fI\fR] +[\fB\-\-force\fR] +[\fB\-\-clean\fR] +[\fB\-\-verbose\fR] +.SH DESCRIPTION +Builds and runs the project. Only available for projects with +\fBkind = "bin"\fR. +.SH OPTIONS +.TP +.B \-\-debug +Run with debug profile (default). +.TP +.B \-\-release +Run with release profile. +.TP +.B \-\-target \fI\fR +Cross-compile for the given target. +.TP +.B \-\-force +Force a full rebuild. +.TP +.B \-\-clean +Clean before building. +.TP +.B \-\-verbose +Print detailed build output. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-build (1) diff --git a/man/man1/dcr-setup.1 b/man/man1/dcr-setup.1 new file mode 100644 index 0000000..0fe61b3 --- /dev/null +++ b/man/man1/dcr-setup.1 @@ -0,0 +1,11 @@ +.TH DCR-SETUP 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-setup \- Set up DCR registries +.SH SYNOPSIS +.B dcr setup +.SH DESCRIPTION +Sets up DCR registries. Downloads and indexes package registries +for dependency resolution. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-add (1) diff --git a/man/man1/dcr-test.1 b/man/man1/dcr-test.1 new file mode 100644 index 0000000..f6ac7ac --- /dev/null +++ b/man/man1/dcr-test.1 @@ -0,0 +1,24 @@ +.TH DCR-TEST 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-test \- Run project tests +.SH SYNOPSIS +.B dcr test +[\fB\-\-init\fR] +[\fB\-\-debug\fR | \fB\-\-release\fR] +.SH ALIASES +.B dcr tests +.SH DESCRIPTION +Runs project tests and prints a unified testsuite report. +.SH OPTIONS +.TP +.B \-\-init +Create \fBtests/dcr_test.h\fR in the current project. +.TP +.B \-\-debug +Build and run tests with debug profile (default). +.TP +.B \-\-release +Build and run tests with release profile. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-build (1) diff --git a/man/man1/dcr-tree.1 b/man/man1/dcr-tree.1 new file mode 100644 index 0000000..0e9da6c --- /dev/null +++ b/man/man1/dcr-tree.1 @@ -0,0 +1,11 @@ +.TH DCR-TREE 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr-tree \- Display the dependency tree +.SH SYNOPSIS +.B dcr tree +.SH DESCRIPTION +Displays the dependency tree of the current project, showing all +transitive dependencies and their versions. +.SH SEE ALSO +.BR dcr (1), +.BR dcr-add (1) diff --git a/man/man1/dcr.1 b/man/man1/dcr.1 new file mode 100644 index 0000000..183c570 --- /dev/null +++ b/man/man1/dcr.1 @@ -0,0 +1,204 @@ +.TH DCR 1 "2026-06-02" "dcr 0.7.0" "DCR Manual" +.SH NAME +dcr \- Cargo\-like build tool and package manager for C/C++ projects +.SH SYNOPSIS +.B dcr +[\fIcommand\fR] [\fIoptions\fR] +.SH DESCRIPTION +DCR is a comprehensive build tool and package manager for C and C++ projects, +inspired by Cargo from the Rust ecosystem. It handles project creation, +building, dependency management, testing, formatting, and IDE integration. +.SH COMMANDS +.TP +.B new \fI\fR +Create a new C/C++ project with the given name. Only ASCII letters, digits, +underscores and hyphens are allowed. +.TP +.B init +Initialize the current (empty) directory as a DCR project. +.TP +.B build [\fIoptions\fR] +Compile the project. Default profile is \fB\-\-debug\fR. +.TP +.B run [\fIoptions\fR] +Build and run the project. Only available for binary projects. +.TP +.B clean [\fIoptions\fR] +Remove build artifacts from the target directory. +.TP +.B test [\fI\-\-init\fR] [\fI\-\-debug\fR|\fI\-\-release\fR] +Run project tests (alias: \fBdcr tests\fR). +.TP +.B add \fI\fR \fI\fR [\fIoptions\fR] +Add a dependency to the project. +.TP +.B tree +Display the dependency tree of the current project. +.TP +.B fmt +Format all C/C++ source files using clang-format. +.TP +.B gen \fI\fR +Generate IDE integration files (vscode, clion, compile-commands, project-info). +.TP +.B setup +Set up DCR registries for dependency resolution. +.SH GLOBAL FLAGS +.TP +.B \-\-help +Show this help message and exit. +.TP +.B \-\-version +Print version information and exit. +.TP +.B \-\-update +Update DCR to the latest version from GitHub Releases. +.SH BUILD OPTIONS +The following options apply to \fBbuild\fR and \fBrun\fR commands: +.TP +.B \-\-debug +Build with debug profile (default). Enables debug symbols and minimal optimization. +.TP +.B \-\-release +Build with release profile. Enables full optimization without debug symbols. +.TP +.B \-\-target \fI\fR +Cross-compile for the given target (e.g. \fBaarch64-linux-gnu\fR, \fBx86_64-w64-mingw32\fR). +Short names like \fBlinux\fR, \fBmacos\fR, \fBwindows\fR are also supported. +.TP +.B \-\-force +Force a full rebuild, ignoring cached build artifacts. +.TP +.B \-\-clean +Clean build artifacts before building. +.TP +.B \-\-verbose +Print detailed build output including compiler commands. +.TP +.B \-\-workspace \fI\fR +Build a specific workspace member. +.SH CLEAN OPTIONS +.TP +.B \-\-debug +Clean debug artifacts (default). +.TP +.B \-\-release +Clean release artifacts. +.TP +.B \-\-target \fI\fR +Clean artifacts for a specific target. +.TP +.B \-\-all +Clean all workspace members. +.SH ADD OPTIONS +.TP +.B \-\-branch \fI\fR +Use a specific branch when adding a git dependency. +.TP +.B \-\-tag \fI\fR +Use a specific tag when adding a git dependency. +.TP +.B \-\-rev \fI\fR +Use a specific commit hash when adding a git dependency. +.SH DEPENDENCY SOURCES +.TP +.B user/repo +GitHub shorthand (e.g. \fBuser/repo\fR). +.TP +.B github:user/repo +Full GitHub repository URL shorthand. +.TP +.B gitlab:user/repo +GitLab repository URL shorthand. +.TP +.B git:host.com/user/repo +Generic git repository. +.TP +.B path:./path/to/lib +Local path dependency. +.TP +.B \fI\fR +Version from registry (e.g. \fB1.2.3\fR). +.SH GEN SUBCOMMANDS +.TP +.B project-info +Print project metadata as JSON to stdout. +.TP +.B compile-commands +Generate \fBcompile_commands.json\fR for IDE tooling. +.TP +.B vscode +Generate \fB.vscode/\fR integration files (tasks, launch configurations). +.TP +.B clion +Generate \fB.idea/\fR integration files for CLion. +.SH TEST OPTIONS +.TP +.B \-\-init +Create \fBtests/dcr_test.h\fR in the current project. +.TP +.B \-\-debug +Build and run tests with debug profile (default). +.TP +.B \-\-release +Build and run tests with release profile. +.SH PROJECT CONFIGURATION +DCR uses \fBdcr.toml\fR for project configuration. Key settings include: +.TP +.B package.name +Project name (required). +.TP +.B package.version +Project version (default: \fB0.1.0\fR). +.TP +.B build.language +Programming language: \fBc\fR or \fBc++\fR (default: \fBc\fR). +.TP +.B build.standard +Language standard (e.g. \fBc11\fR, \fBc17\fR, \fBc++20\fR; default: \fBc11\fR). +.TP +.B build.compiler +Compiler to use: \fBclang\fR, \fBgcc\fR, \fBcl\fR, \fBclang-cl\fR (default: \fBclang\fR). +.TP +.B build.kind +Output type: \fBbin\fR, \fBlib\fR (static or dynamic), \fBstaticlib\fR, \fBsharedlib\fR (default: \fBbin\fR). +.SH FILES +.TP +.I dcr.toml +Project manifest file. +.TP +.I ~/.dcr/config.toml +User-level DCR configuration. +.TP +.I ~/.dcr/index.json +Local registry index. +.SH ENVIRONMENT +.TP +.B DCR_COMPILER +Override the compiler used for building. +.TP +.B DCR_CC +Alternative way to override the compiler. +.SH EXAMPLES +.TP +Create a new project: +.B dcr new hello +.TP +Initialize from current directory: +.B dcr init +.TP +Build with release profile: +.B dcr build \-\-release +.TP +Cross-compile for Windows: +.B dcr build \-\-target windows +.TP +Add a dependency: +.BR "dcr add curl git:https://github.com/curl/curl" . +.TP +Generate VS Code integration: +.B dcr gen vscode +.SH SEE ALSO +.IR https://dcr.dexoron.su ", " https://github.com/dexoron/dcr +.SH AUTHORS +Dexoron (Bezotechestvo Vladimir) diff --git a/packaging/aur/dcr/PKGBUILD b/packaging/aur/dcr/PKGBUILD index 467e392..f6ce0c9 100644 --- a/packaging/aur/dcr/PKGBUILD +++ b/packaging/aur/dcr/PKGBUILD @@ -27,4 +27,7 @@ package() { cd "$srcdir/$pkgname-$pkgver" install -Dm755 "target/release/dcr" "$pkgdir/usr/bin/dcr" install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" + for manpage in man/man1/*.1; do + install -Dm644 "$manpage" "$pkgdir/usr/share/man/man1/$(basename "$manpage")" + done } diff --git a/src/cli/add.rs b/src/cli/add.rs index f0ef5a2..109c801 100644 --- a/src/cli/add.rs +++ b/src/cli/add.rs @@ -19,7 +19,7 @@ use crate::core::config::Config; use crate::core::deps::register; use crate::utils::fs::find_project_root; use crate::utils::log::error; -use crate::utils::text::{BOLD_GREEN, colored}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; use toml::Value; use toml::map::Map; @@ -34,6 +34,28 @@ pub struct AddArgs { } pub fn add(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr add [--branch ] [--tag ] [--rev ]", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Adds a dependency to the project."); + println!(); + printc("SOURCES:", BOLD_GREEN); + println!(" user/repo GitHub shorthand"); + println!(" github:user/repo GitHub repository"); + println!(" gitlab:user/repo GitLab repository"); + println!(" git:host.com/user/repo Generic git repository"); + println!(" path:./path/to/lib Local path dependency"); + println!(" Version from registry"); + println!(); + printc("OPTIONS:", BOLD_GREEN); + println!(" --branch Use a specific branch"); + println!(" --tag Use a specific tag"); + println!(" --rev Use a specific commit hash"); + return 0; + } + let add_args = match parse_add_args(args) { Ok(a) => a, Err(code) => return code, diff --git a/src/cli/build.rs b/src/cli/build.rs index 53d7691..92ade3c 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -29,7 +29,7 @@ use crate::utils::build::{ }; use crate::utils::fs::{check_dir, find_project_root, with_dir}; use crate::utils::log::error; -use crate::utils::text::{BOLD_GREEN, colored}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; use glob::glob; use sha2::{Digest, Sha256}; use std::fs; @@ -42,6 +42,24 @@ static BUILD_INTERRUPTED: AtomicBool = AtomicBool::new(false); static SIGNAL_HANDLER: Once = Once::new(); pub fn build(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr build [--debug | --release] [--target ] [--force] [--clean] [--verbose]", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Compiles the project. Default profile is --debug."); + println!(); + printc("OPTIONS:", BOLD_GREEN); + println!(" --debug Build with debug profile (default)"); + println!(" --release Build with release profile"); + println!(" --target Cross-compile for the given target"); + println!(" --force Force a full rebuild"); + println!(" --clean Clean before building"); + println!(" --verbose Print detailed build output"); + println!(" --workspace Build a specific workspace member"); + return 0; + } + install_signal_handler(); BUILD_INTERRUPTED.store(false, Ordering::SeqCst); let start_dir = match std::env::current_dir() { diff --git a/src/cli/clean.rs b/src/cli/clean.rs index 73e82bc..9d91d87 100644 --- a/src/cli/clean.rs +++ b/src/cli/clean.rs @@ -21,12 +21,27 @@ use crate::core::workspace::parse_workspace; use crate::utils::build::parse_version_info; use crate::utils::fs::{check_dir, find_project_root, with_dir}; use crate::utils::log::{error, warn}; -use crate::utils::text::{BOLD_GREEN, colored}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; use glob::glob; use std::fs; use std::path::Path; pub fn clean(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr clean [--debug | --release] [--target ] [--all]", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Removes build artifacts from the target directory."); + println!(); + printc("OPTIONS:", BOLD_GREEN); + println!(" --debug Clean debug artifacts (default)"); + println!(" --release Clean release artifacts"); + println!(" --target Clean artifacts for a specific target"); + println!(" --all Clean all workspace members"); + return 0; + } + let start_dir = match std::env::current_dir() { Ok(dir) => dir, Err(_) => { diff --git a/src/cli/flag_update.rs b/src/cli/flag_update.rs index 64c7b72..31f3bfb 100644 --- a/src/cli/flag_update.rs +++ b/src/cli/flag_update.rs @@ -16,6 +16,7 @@ // along with this program. If not, see . use crate::utils::log::{error, warn}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc}; use reqwest::blocking::Client; use serde::Deserialize; use std::fs; @@ -39,6 +40,15 @@ struct ReleaseAsset { } pub fn flag_update(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr --update", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Updates DCR to the latest version from GitHub Releases."); + return 0; + } + if !args.is_empty() { warn("Command does not support additional arguments"); return 1; diff --git a/src/cli/fmt.rs b/src/cli/fmt.rs index 6517fa8..4086e95 100644 --- a/src/cli/fmt.rs +++ b/src/cli/fmt.rs @@ -16,11 +16,21 @@ // along with this program. If not, see . use crate::utils::log::error; -use crate::utils::text::{BOLD_GREEN, colored}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; use glob::glob; use std::process::Command; -pub fn fmt(_args: &[String]) -> i32 { +pub fn fmt(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr fmt", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Formats all C/C++ source files using clang-format."); + println!(" Scans src/ and tests/ directories recursively."); + return 0; + } + let patterns = [ "src/**/*.c", "src/**/*.cpp", diff --git a/src/cli/gen.rs b/src/cli/gen.rs index b35aaba..c879a9e 100644 --- a/src/cli/gen.rs +++ b/src/cli/gen.rs @@ -27,6 +27,7 @@ use crate::utils::build::{ }; use crate::utils::fs::find_project_root; use crate::utils::log::error; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc}; use std::path::{Path, PathBuf}; /// Like `deps::resolve_deps` but does NOT require lib directories to exist. @@ -186,13 +187,30 @@ 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 ", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Generates IDE and tooling integration files."); + println!(); + printc("SUBCOMMANDS:", BOLD_GREEN); + println!(" project-info Print project metadata as JSON"); + println!(" compile-commands Generate compile_commands.json"); + println!(" vscode Generate .vscode/ integration files"); + println!(" clion Generate .idea/ integration files"); + return 0; + } Some(s) => s.as_str(), None => { - eprintln!("Usage: dcr gen "); - eprintln!(" project-info Print project metadata as JSON"); - eprintln!(" compile-commands Generate compile_commands.json"); - eprintln!(" vscode Generate .vscode/ integration files"); - eprintln!(" clion Generate .idea/ integration files"); + printc("USAGE:", BOLD_GREEN); + printc(" dcr gen ", BOLD_CYAN); + println!(); + printc("SUBCOMMANDS:", BOLD_GREEN); + println!(" project-info Print project metadata as JSON"); + println!(" compile-commands Generate compile_commands.json"); + println!(" vscode Generate .vscode/ integration files"); + println!(" clion Generate .idea/ integration files"); return 1; } }; diff --git a/src/cli/init.rs b/src/cli/init.rs index 76d2d16..6adc96d 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -25,6 +25,16 @@ use std::io::Write; use toml::Value; pub fn init(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr init", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Initializes the current directory as a DCR project."); + println!(" The directory must be empty."); + return 0; + } + if !args.is_empty() { warn("Command does not support additional arguments"); return 1; diff --git a/src/cli/new.rs b/src/cli/new.rs index bcc942d..943ecb1 100644 --- a/src/cli/new.rs +++ b/src/cli/new.rs @@ -25,6 +25,16 @@ use std::io::Write; use toml::Value; pub fn new(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr new ", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Creates a new C/C++ project with the given name."); + println!(" The name may only contain ASCII letters, digits, '_' and '-'."); + return 0; + } + let items = check_dir(None).unwrap_or_default(); if args.is_empty() { diff --git a/src/cli/run.rs b/src/cli/run.rs index cd6b858..45c149f 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -23,7 +23,7 @@ use crate::utils::build::{normalize_target_os, parse_version_info}; use crate::utils::fs::find_project_root; use crate::utils::fs::with_dir; use crate::utils::log::error; -use crate::utils::text::{BOLD_GREEN, colored}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; use std::path::Path; use std::process::Command; @@ -56,6 +56,23 @@ fn get_run_cmd( } pub fn run(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr run [--debug | --release] [--target ] [--force] [--clean] [--verbose]", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Builds and runs the project. Only available for kind = \"bin\"."); + println!(); + printc("OPTIONS:", BOLD_GREEN); + println!(" --debug Run with debug profile (default)"); + println!(" --release Run with release profile"); + println!(" --target Cross-compile for the given target"); + println!(" --force Force a full rebuild"); + println!(" --clean Clean before building"); + println!(" --verbose Print detailed build output"); + return 0; + } + let start_dir = match std::env::current_dir() { Ok(dir) => dir, Err(_) => { diff --git a/src/cli/setup.rs b/src/cli/setup.rs index 62bf03c..75d3d9f 100644 --- a/src/cli/setup.rs +++ b/src/cli/setup.rs @@ -15,7 +15,19 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -pub fn setup(_args: &[String]) -> i32 { +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc}; + +pub fn setup(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr setup", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Sets up DCR registries. Downloads and indexes"); + println!(" package registries for dependency resolution."); + return 0; + } + println!("Setting up DCR registries..."); match crate::core::registry::RegistryManager::load() { Ok(manager) => { diff --git a/src/cli/test.rs b/src/cli/test.rs index b30d4b5..335ebb1 100644 --- a/src/cli/test.rs +++ b/src/cli/test.rs @@ -24,7 +24,7 @@ use crate::utils::build::{ }; use crate::utils::fs::{find_project_root, with_dir}; use crate::utils::log::error; -use crate::utils::text::{BOLD_GREEN, BOLD_RED, RESET, colored}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, BOLD_RED, RESET, colored, printc}; use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; @@ -36,16 +36,16 @@ pub fn test(args: &[String]) -> i32 { let mut profile = "debug"; for arg in args { if arg == "--help" { - println!("USAGE:"); - println!(" dcr test [--init] [--debug | --release]"); + printc("USAGE:", BOLD_GREEN); + printc(" dcr test [--init] [--debug | --release]", BOLD_CYAN); println!(); - println!("ALIASES:"); + printc("ALIASES:", BOLD_GREEN); println!(" dcr tests"); println!(); - println!("DESCRIPTION:"); + printc("DESCRIPTION:", BOLD_GREEN); println!(" Runs project tests and prints a unified testsuite report."); println!(); - println!("OPTIONS:"); + printc("OPTIONS:", BOLD_GREEN); 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"); diff --git a/src/cli/tree.rs b/src/cli/tree.rs index 220db40..d8e6bcd 100644 --- a/src/cli/tree.rs +++ b/src/cli/tree.rs @@ -17,12 +17,21 @@ use crate::core::config::Config; use crate::utils::log::error; -use crate::utils::text::{BOLD_CYAN, printc}; +use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc}; use std::collections::HashSet; use std::path::{Path, PathBuf}; use toml::Value; -pub fn tree(_args: &[String]) -> i32 { +pub fn tree(args: &[String]) -> i32 { + if args.first().map_or(false, |a| a == "--help") { + printc("USAGE:", BOLD_GREEN); + printc(" dcr tree", BOLD_CYAN); + println!(); + printc("DESCRIPTION:", BOLD_GREEN); + println!(" Displays the dependency tree of the current project."); + return 0; + } + let current_dir = std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")); let config = match Config::open("dcr.toml") { Ok(c) => c,