diff options
47 files changed, 12724 insertions, 6141 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f75882d3..3254e054 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,7 @@ jobs: include: - build: pinned os: ubuntu-latest - rust: 1.72.1 + rust: 1.74.0 - build: stable os: ubuntu-latest rust: stable @@ -94,7 +94,7 @@ jobs: rust: nightly-x86_64-gnu steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install packages (Ubuntu) if: matrix.os == 'ubuntu-latest' @@ -131,6 +131,7 @@ jobs: run: | echo "cargo command is: ${{ env.CARGO }}" echo "target flag is: ${{ env.TARGET_FLAGS }}" + echo "target dir is: ${{ env.TARGET_DIR }}" - name: Build ripgrep and all crates run: ${{ env.CARGO }} build --verbose --workspace ${{ env.TARGET_FLAGS }} @@ -164,26 +165,6 @@ jobs: if: matrix.target != '' run: ${{ env.CARGO }} test --verbose --workspace ${{ env.TARGET_FLAGS }} - - name: Test for existence of build artifacts (Windows) - if: matrix.os == 'windows-2022' - shell: bash - run: | - outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")" - ls "$outdir/_rg.ps1" && file "$outdir/_rg.ps1" - - - name: Test for existence of build artifacts (Unix) - if: matrix.os != 'windows-2022' - shell: bash - run: | - outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")" - # TODO: Check for the man page generation here. For whatever reason, - # it seems to be intermittently failing in CI. No idea why. - # for f in rg.bash rg.fish rg.1; do - for f in rg.bash rg.fish; do - # We could use file -E here, but it isn't supported on macOS. - ls "$outdir/$f" && file "$outdir/$f" - done - - name: Test zsh shell completions (Unix, sans cross) # We could test this when using Cross, but we'd have to execute the # 'rg' binary (done in test-complete) with qemu, which is a pain and @@ -197,11 +178,15 @@ jobs: shell: bash run: ${{ env.CARGO }} test --manifest-path crates/cli/Cargo.toml ${{ env.TARGET_FLAGS }} --lib print_hostname -- --nocapture + - name: Print available short flags + shell: bash + run: ${{ env.CARGO }} test --bin rg ${{ env.TARGET_FLAGS }} flags::defs::tests::available_shorts -- --nocapture + rustfmt: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@master with: @@ -214,7 +199,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Rust uses: dtolnay/rust-toolchain@master with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b307ce5e..dc732771 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,47 +1,39 @@ -# The way this works is the following: -# -# The create-release job runs purely to initialize the GitHub release itself -# and to output upload_url for the following job. -# -# The build-release job runs only once create-release is finished. It gets the -# release upload URL from create-release job outputs, then builds the release -# executables for each supported platform and attaches them as release assets -# to the previously created release. -# -# The key here is that we create the release only once. -# -# Reference: -# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/ - name: release + +# Only do the release on x.y.z tags. on: push: - # Enable when testing release infrastructure on a branch. - # branches: - # - ag/work tags: - "[0-9]+.[0-9]+.[0-9]+" + +# We need this to be able to create releases. +permissions: + contents: write + jobs: + # The create-release job runs purely to initialize the GitHub release itself, + # and names the release after the `x.y.z` tag that was pushed. It's separate + # from building the release so that we only create the release once. create-release: name: create-release runs-on: ubuntu-latest # env: # Set to force version number, e.g., when no tag exists. - # RG_VERSION: TEST-0.0.0 - outputs: - rg_version: ${{ env.RG_VERSION }} + # VERSION: TEST-0.0.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Get the release version from the tag - shell: bash - if: env.RG_VERSION == '' + if: env.VERSION == '' + run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + - name: Show the version run: | - echo "RG_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV - echo "version is: ${{ env.RG_VERSION }}" + echo "version is: $VERSION" - name: Create GitHub release env: - GH_TOKEN: ${{ github.token }} - run: gh release create ${{ env.RG_VERSION }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release create $VERSION --draft --verify-tag --title $VERSION + outputs: + version: ${{ env.VERSION }} build-release: name: build-release @@ -52,25 +44,50 @@ jobs: # systems. CARGO: cargo # When CARGO is set to CROSS, this is set to `--target matrix.target`. - TARGET_FLAGS: "" + TARGET_FLAGS: # When CARGO is set to CROSS, TARGET_DIR includes matrix.target. TARGET_DIR: ./target + # Bump this as appropriate. We pin to a version to make sure CI + # continues to work as cross releases in the past have broken things + # in subtle ways. + CROSS_VERSION: v0.2.5 # Emit backtraces on panics. RUST_BACKTRACE: 1 # Build static releases with PCRE2. PCRE2_SYS_STATIC: 1 strategy: + fail-fast: false matrix: - build: [linux, linux-arm, macos, win-msvc, win-gnu, win32-msvc] include: - build: linux os: ubuntu-latest rust: nightly target: x86_64-unknown-linux-musl - - build: linux-arm + strip: x86_64-linux-musl-strip + - build: stable-x86 os: ubuntu-latest - rust: nightly - target: arm-unknown-linux-gnueabihf + rust: stable + target: i686-unknown-linux-gnu + strip: x86_64-linux-gnu-strip + qemu: i386 + - build: stable-aarch64 + os: ubuntu-latest + rust: stable + target: aarch64-unknown-linux-gnu + strip: aarch64-linux-gnu-strip + qemu: qemu-aarch64 + - build: stable-powerpc64 + os: ubuntu-latest + rust: stable + target: powerpc64-unknown-linux-gnu + strip: powerpc64-linux-gnu-strip + qemu: qemu-ppc64 + - build: stable-s390x + os: ubuntu-latest + rust: stable + target: s390x-unknown-linux-gnu + strip: s390x-linux-gnu-strip + qemu: qemu-s390x - build: macos os: macos-latest rust: nightly @@ -90,15 +107,17 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install packages (Ubuntu) if: matrix.os == 'ubuntu-latest' + shell: bash run: | ci/ubuntu-install-packages - name: Install packages (macOS) if: matrix.os == 'macos-latest' + shell: bash run: | ci/macos-install-packages @@ -109,64 +128,140 @@ jobs: target: ${{ matrix.target }} - name: Use Cross + if: matrix.os == 'ubuntu-latest' && matrix.target != '' shell: bash run: | - cargo install cross + # In the past, new releases of 'cross' have broken CI. So for now, we + # pin it. We also use their pre-compiled binary releases because cross + # has over 100 dependencies and takes a bit to compile. + dir="$RUNNER_TEMP/cross-download" + mkdir "$dir" + echo "$dir" >> $GITHUB_PATH + cd "$dir" + curl -LO "https://github.com/cross-rs/cross/releases/download/$CROSS_VERSION/cross-x86_64-unknown-linux-musl.tar.gz" + tar xf cross-x86_64-unknown-linux-musl.tar.gz echo "CARGO=cross" >> $GITHUB_ENV + + - name: Set target variables + shell: bash + run: | echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV - name: Show command used for Cargo + shell: bash run: | echo "cargo command is: ${{ env.CARGO }}" echo "target flag is: ${{ env.TARGET_FLAGS }}" echo "target dir is: ${{ env.TARGET_DIR }}" - name: Build release binary - run: ${{ env.CARGO }} build --verbose --release --features pcre2 ${{ env.TARGET_FLAGS }} + shell: bash + run: | + ${{ env.CARGO }} build --verbose --release --features pcre2 ${{ env.TARGET_FLAGS }} + if [ "${{ matrix.os }}" = "windows-latest" ]; then + bin="target/${{ matrix.target }}/release/rg.exe" + else + bin="target/${{ matrix.target }}/release/rg" + fi + echo "BIN=$bin" >> $GITHUB_ENV - - name: Strip release binary (linux, macos and macos-arm) - if: matrix.build == 'linux' || matrix.os == 'macos' - run: strip "target/${{ matrix.target }}/release/rg" + - name: Strip release binary (macos) + if: matrix.os == 'macos' + shell: bash + run: strip "$BIN" - - name: Strip release binary (arm) - if: matrix.build == 'linux-arm' + - name: Strip release binary (cross) + if: env.CARGO == 'cross' + shell: bash run: | docker run --rm -v \ "$PWD/target:/target:Z" \ - rustembedded/cross:arm-unknown-linux-gnueabihf \ - arm-linux-gnueabihf-strip \ - /target/arm-unknown-linux-gnueabihf/release/rg + "rustembedded/cross:${{ matrix.target }}" \ + "${{ matrix.strip }}" \ + "/target/${{ matrix.target }}/release/rg" - - name: Build archive + - name: Determine archive name shell: bash run: | - outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")" - staging="ripgrep-${{ needs.create-release.outputs.rg_version }}-${{ matrix.target }}" - mkdir -p "$staging"/{complete,doc} + version="${{ needs.create-release.outputs.version }}" + echo "ARCHIVE=ripgrep-$version-${{ matrix.target }}" >> $GITHUB_ENV - cp {README.md,COPYING,UNLICENSE,LICENSE-MIT} "$staging/" - cp {CHANGELOG.md,FAQ.md,GUIDE.md} "$staging/doc/" - cp "$outdir"/{rg.bash,rg.fish,_rg.ps1} "$staging/complete/" - cp complete/_rg "$staging/complete/" + - name: Creating directory for archive + shell: bash + run: | + mkdir -p "$ARCHIVE"/{complete,doc} + cp "$BIN" "$ARCHIVE"/ + cp {README.md,COPYING,UNLICENSE,LICENSE-MIT} "$ARCHIVE"/ + cp {CHANGELOG.md,FAQ.md,GUIDE.md} "$ARCHIVE"/doc/ - if [ "${{ matrix.os }}" = "windows-latest" ]; then - cp "target/${{ matrix.target }}/release/rg.exe" "$staging/" - 7z a "$staging.zip" "$staging" - certutil -hashfile "$staging.zip" SHA256 > "$staging.zip.sha256" - echo "ASSET=$staging.zip" >> $GITHUB_ENV - echo "ASSET_SUM=$staging.zip.sha256" >> $GITHUB_ENV - else - # The man page is only generated on Unix systems. ¯\_(ツ)_/¯ - cp "$outdir"/rg.1 "$staging/doc/" - cp "target/${{ matrix.target }}/release/rg" "$staging/" - tar czf "$staging.tar.gz" "$staging" - shasum -a 256 "$staging.tar.gz" > "$staging.tar.gz.sha256" - echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV - echo "ASSET_SUM=$staging.tar.gz.sha256" >> $GITHUB_ENV - fi + - name: Generate man page and completions (no emulation) + if: matrix.qemu == '' + shell: bash + run: | + "$BIN" --version + "$BIN" --generate complete-bash > "$ARCHIVE/complete/rg.bash" + "$BIN" --generate complete-fish > "$ARCHIVE/complete/rg.fish" + "$BIN" --generate complete-powershell > "$ARCHIVE/complete/_rg.ps1" + "$BIN" --generate complete-zsh > "$ARCHIVE/complete/_rg" + "$BIN" --generate man > "$ARCHIVE/doc/rg.1" + + - name: Generate man page and completions (emulation) + if: matrix.qemu != '' + shell: bash + run: | + docker run --rm -v \ + "$PWD/target:/target:Z" \ + "rustembedded/cross:${{ matrix.target }}" \ + "${{ matrix.qemu }}" "/$BIN" --version + docker run --rm -v \ + "$PWD/target:/target:Z" \ + "rustembedded/cross:${{ matrix.target }}" \ + "${{ matrix.qemu }}" "/$BIN" \ + --generate complete-bash > "$ARCHIVE/complete/rg.bash" + docker run --rm -v \ + "$PWD/target:/target:Z" \ + "rustembedded/cross:${{ matrix.target }}" \ + "${{ matrix.qemu }}" "/$BIN" \ + --generate complete-fish > "$ARCHIVE/complete/rg.fish" + docker run --rm -v \ + "$PWD/target:/target:Z" \ + "rustembedded/cross:${{ matrix.target }}" \ + "${{ matrix.qemu }}" "/$BIN" \ + --generate complete-powershell > "$ARCHIVE/complete/_rg.ps1" + docker run --rm -v \ + "$PWD/target:/target:Z" \ + "rustembedded/cross:${{ matrix.target }}" \ + "${{ matrix.qemu }}" "/$BIN" \ + --generate complete-zsh > "$ARCHIVE/complete/_rg" + docker run --rm -v \ + "$PWD/target:/target:Z" \ + "rustembedded/cross:${{ matrix.target }}" \ + "${{ matrix.qemu }}" "/$BIN" \ + --generate man > "$ARCHIVE/doc/rg.1" + + - name: Build archive (Windows) + shell: bash + if: matrix.os == 'windows-latest' + run: | + 7z a "$ARCHIVE.zip" "$ARCHIVE" + certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256" + echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV + echo "ASSET_SUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV + + - name: Build archive (Unix) + shell: bash + if: matrix.os != 'windows-latest' + run: | + tar czf "$ARCHIVE.tar.gz" "$ARCHIVE" + shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256" + echo "ASSET=$ARCHIVE.tar.gz" >> $GITHUB_ENV + echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >> $GITHUB_ENV - name: Upload release archive env: - GH_TOKEN: ${{ github.token }} - run: gh release upload ${{ needs.create-release.outputs.rg_version }} ${{ env.ASSET }} ${{ env.ASSET_SUM }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + version="${{ needs.create-release.outputs.version }}" + gh release upload "$version" ${{ env.ASSET }} ${{ env.ASSET_SUM }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de53e23..d390ae3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ Feature enhancements: Gradle, GraphQL, Markdown, Prolog, Raku, TypeScript, USD, V * [FEATURE #1790](https://github.com/BurntSushi/ripgrep/issues/1790): Add new `--stop-on-nonmatch` flag. +* [FEATURE #1814](https://github.com/BurntSushi/ripgrep/issues/1814): + Flags are now categorized in `-h/--help` output and ripgrep's man page. * [FEATURE #2195](https://github.com/BurntSushi/ripgrep/issues/2195): When `extra-verbose` mode is enabled in zsh, show extra file type info. * [FEATURE #2409](https://github.com/BurntSushi/ripgrep/pull/2409): @@ -28,14 +30,22 @@ Feature enhancements: Bug fixes: +* [BUG #884](https://github.com/BurntSushi/ripgrep/issues/884): + Don't error when `-v/--invert-match` is used multiple times. * [BUG #1275](https://github.com/BurntSushi/ripgrep/issues/1275): Fix bug with `\b` assertion in the regex engine. +* [BUG #1648](https://github.com/BurntSushi/ripgrep/issues/1648): + Fix bug where sometimes short flags with values, e.g., `-M 900`, would fail. +* [BUG #1701](https://github.com/BurntSushi/ripgrep/issues/1701): + Fix bug where some flags could not be repeated. * [BUG #1757](https://github.com/BurntSushi/ripgrep/issues/1757): Fix bug when searching a sub-directory didn't have ignores applied correctly. * [BUG #1891](https://github.com/BurntSushi/ripgrep/issues/1891): Fix bug when using `-w` with a regex that can match the empty string. * [BUG #1911](https://github.com/BurntSushi/ripgrep/issues/1911): Disable mmap searching in all non-64-bit environments. +* [BUG #1966](https://github.com/BurntSushi/ripgrep/issues/1966): + Fix bug where ripgrep can panic when printing to stderr. * [BUG #2108](https://github.com/BurntSushi/ripgrep/issues/2108): Improve docs for `-r/--replace` syntax. * [BUG #2198](https://github.com/BurntSushi/ripgrep/issues/2198): @@ -30,12 +30,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] name = "bstr" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -63,18 +57,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "bitflags", - "strsim", - "textwrap", - "unicode-width", -] - -[[package]] name = "crossbeam-channel" version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -292,6 +274,12 @@ dependencies = [ ] [[package]] +name = "lexopt" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401" + +[[package]] name = "libc" version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -434,15 +422,16 @@ version = "13.0.0" dependencies = [ "anyhow", "bstr", - "clap", "grep", "ignore", "jemallocator", + "lexopt", "log", "serde", "serde_derive", "serde_json", "termcolor", + "textwrap", "walkdir", ] @@ -499,12 +488,6 @@ dependencies = [ ] [[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - -[[package]] name = "syn" version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -517,21 +500,18 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] [[package]] name = "textwrap" -version = "0.11.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "unicode-ident" @@ -540,12 +520,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] name = "walkdir" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -50,26 +50,18 @@ members = [ [dependencies] anyhow = "1.0.75" -bstr = "1.6.0" +bstr = "1.7.0" grep = { version = "0.2.12", path = "crates/grep" } ignore = { version = "0.4.19", path = "crates/ignore" } +lexopt = "0.3.0" log = "0.4.5" serde_json = "1.0.23" termcolor = "1.1.0" - -[dependencies.clap] -version = "2.33.0" -default-features = false -features = ["suggestions"] +textwrap = { version = "0.16.0", default-features = false } [target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator] version = "0.5.0" -[build-dependencies.clap] -version = "2.33.0" -default-features = false -features = ["suggestions"] - [dev-dependencies] serde = "1.0.77" serde_derive = "1.0.77" diff --git a/RELEASE-CHECKLIST.md b/RELEASE-CHECKLIST.md index 7d56dfee..39b0c730 100644 --- a/RELEASE-CHECKLIST.md +++ b/RELEASE-CHECKLIST.md @@ -1,11 +1,12 @@ -Release Checklist ------------------ +# Release Checklist + * Ensure local `master` is up to date with respect to `origin/master`. * Run `cargo update` and review dependency updates. Commit updated `Cargo.lock`. * Run `cargo outdated` and review semver incompatible updates. Unless there is a strong motivation otherwise, review and update every dependency. Also run `--aggressive`, but don't update to crates that are still in beta. +* Update date in `crates/core/flags/doc/template.rg.1`. * Review changes for every crate in `crates` since the last ripgrep release. If the set of changes is non-empty, issue a new release for that crate. Check crates in the following order. After updating a crate, ensure minimal @@ -39,8 +40,10 @@ Release Checklist > tool that recursively searches the current directory for a regex pattern. > By default, ripgrep will respect gitignore rules and automatically skip > hidden files/directories and binary files. -* Run `ci/build-deb` locally and manually upload the deb package to the - release. +* Run `git checkout $version && ci/build-and-publish-deb $version` on a Linux + system that has `cargo deb` installed. +* Run `git checkout $version && ci/build-and-publish-m2 $version` on a macOS + system with Apple silicon. * Run `cargo publish`. * Run `ci/sha256-releases {VERSION} >> pkg/brew/ripgrep-bin.rb`. Then edit `pkg/brew/ripgrep-bin.rb` to update the version number and sha256 hashes. @@ -52,5 +55,6 @@ Release Checklist Unreleased changes. Release notes have not yet been written. ``` -Note that -[`cargo-up` can be found in BurntSushi's dotfiles](https://github.com/BurntSushi/dotfiles/blob/master/bin/cargo-up). +Note that [`cargo-up` can be found in BurntSushi's dotfiles][dotfiles]. + +[dotfiles]: https://github.com/BurntSushi/dotfiles/blob/master/bin/cargo-up @@ -1,70 +1,24 @@ -use std::{ - env, - fs::{self, File}, - io::{self, Read, Write}, - path::Path, - process, -}; - -use clap::Shell; - -use crate::app::{RGArg, RGArgKind}; - -#[allow(dead_code)] -#[path = "crates/core/app.rs"] -mod app; - fn main() { - // OUT_DIR is set by Cargo and it's where any additional build artifacts - // are written. - let Some(outdir) = env::var_os("OUT_DIR") else { - eprintln!( - "OUT_DIR environment variable not defined. \ - Please file a bug: \ - https://github.com/BurntSushi/ripgrep/issues/new" - ); - process::exit(1); - }; - fs::create_dir_all(&outdir).unwrap(); - - let stamp_path = Path::new(&outdir).join("ripgrep-stamp"); - if let Err(err) = File::create(&stamp_path) { - panic!("failed to write {}: {}", stamp_path.display(), err); - } - if let Err(err) = generate_man_page(&outdir) { - eprintln!("failed to generate man page: {}", err); - } - - // Use clap to build completion files. - let mut app = app::app(); - app.gen_completions("rg", Shell::Bash, &outdir); - app.gen_completions("rg", Shell::Fish, &outdir); - app.gen_completions("rg", Shell::PowerShell, &outdir); - // Note that we do not use clap's support for zsh. Instead, zsh completions - // are manually maintained in `complete/_ |