Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: make it possible to override generate dirs via env #1658

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fgimian
Copy link

@fgimian fgimian commented Jan 7, 2025

Description

This change simply makes it possible to optionally specify COMPLETION_DIR or MANPAGE_DIR via environment variables to specify the location where completion and manpage files are created. This is especially handy when using cargo install and is a similar approach used by hyperfine.

This also makes sure the docs align with the implementation as build_process.md states the following:

  • Build a release build with:

    • --features deploy, which enables only crates needed for release builds.

    • --locked to lock the dependency versions.

    • The following env variables set:

      • BTM_GENERATE: true
      • COMPLETION_DIR: "target/tmp/bottom/completion/"
      • MANPAGE_DIR: "target/tmp/bottom/manpage/"

Issue

Partially addresses #1654 for those using cargo install

Testing

Windows

~\source\bottom on  allow_generate_customization_via_env is 📦 v0.11.0 via 🦀 v1.85.0-nightly
🕙 [ 08:18:10 PM ] ❯ ls C:\Users\Fots\Downloads\bottom-generation
Get-ChildItem: Cannot find path 'C:\Users\Fots\Downloads\bottom-generation' because it does not exist.

~\source\bottom on  allow_generate_customization_via_env is 📦 v0.11.0 via 🦀 v1.85.0-nightly
🕙 [ 08:18:10 PM ] ❯ $env:BTM_GENERATE = '1'

~\source\bottom on  allow_generate_customization_via_env is 📦 v0.11.0 via 🦀 v1.85.0-nightly
🕙 [ 08:18:13 PM ] ❯ $env:COMPLETION_DIR = 'C:\Users\Fots\Downloads\bottom-generation'

~\source\bottom on  allow_generate_customization_via_env is 📦 v0.11.0 via 🦀 v1.85.0-nightly
🕙 [ 08:18:15 PM ] ❯ $env:MANPAGE_DIR = 'C:\Users\Fots\Downloads\bottom-generation'

~\source\bottom on  allow_generate_customization_via_env is 📦 v0.11.0 via 🦀 v1.85.0-nightly
🕙 [ 08:18:16 PM ] ❯ cargo build
   Compiling bottom v0.11.0 (C:\Users\Fots\source\bottom)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.02s

~\source\bottom on  allow_generate_customization_via_env is 📦 v0.11.0 via 🦀 v1.85.0-nightly took 4s
🕙 [ 08:18:22 PM ] ❯ ls C:\Users\Fots\Downloads\bottom-generation

    Directory: C:\Users\Fots\Downloads\bottom-generation

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---           7/01/2025  8:18 PM           5155 _btm
-a---           7/01/2025  8:18 PM          10734 _btm.ps1
-a---           7/01/2025  8:18 PM           9025 btm.1
-a---           7/01/2025  8:18 PM           4110 btm.bash
-a---           7/01/2025  8:18 PM           5477 btm.elv
-a---           7/01/2025  8:18 PM           4315 btm.fish
-a---           7/01/2025  8:18 PM           4457 btm.nu
-a---           7/01/2025  8:18 PM           7403 btm.ts

Linux

fots@Fotsies-PC:~/bottom$ ls -l ~/
total 4
drwxr-xr-x 16 fots fots 4096 Jan  7 20:33 bottom
fots@Fotsies-PC:~/bottom$ export BTM_GENERATE=1
fots@Fotsies-PC:~/bottom$ export COMPLETION_DIR=/home/fots/bottom-generate-completions
fots@Fotsies-PC:~/bottom$ export MANPAGE_DIR=/home/fots/bottom-generate-manpage
fots@Fotsies-PC:~/bottom$ cargo build
   Compiling bottom v0.11.0 (/home/fots/bottom)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.51s
fots@Fotsies-PC:~/bottom$ ls -l ~/
total 12
drwxr-xr-x 16 fots fots 4096 Jan  7 20:33 bottom
drwxr-xr-x  2 fots fots 4096 Jan  7 20:34 bottom-generate-completions
drwxr-xr-x  2 fots fots 4096 Jan  7 20:34 bottom-generate-manpage
fots@Fotsies-PC:~/bottom$ ls -l ~/bottom-generate-*
/home/fots/bottom-generate-completions:
total 60
-rw-r--r-- 1 fots fots  5241 Jan  7 20:34 _btm
-rw-r--r-- 1 fots fots 10921 Jan  7 20:34 _btm.ps1
-rw-r--r-- 1 fots fots  4132 Jan  7 20:34 btm.bash
-rw-r--r-- 1 fots fots  5577 Jan  7 20:34 btm.elv
-rw-r--r-- 1 fots fots  4418 Jan  7 20:34 btm.fish
-rw-r--r-- 1 fots fots  4548 Jan  7 20:34 btm.nu
-rw-r--r-- 1 fots fots  7534 Jan  7 20:34 btm.ts

/home/fots/bottom-generate-manpage:
total 12
-rw-r--r-- 1 fots fots 9150 Jan  7 20:34 btm.1
  • Windows
  • macOS
  • Linux

Checklist

If relevant, ensure the following have been met:

  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • The change has been tested and doesn't appear to cause any unintended breakage
  • Documentation has been added/updated if needed (README.md, help menu, doc pages, etc.)
  • The pull request passes the provided CI pipeline
  • There are no merge conflicts
  • If relevant, new tests were added (don't worry too much about coverage) - N/A, only changes the build.rs script 😄

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 53.82%. Comparing base (c9ffc41) to head (16e678b).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1658       +/-   ##
===========================================
+ Coverage   41.32%   53.82%   +12.50%     
===========================================
  Files         109      109               
  Lines       17900    17900               
===========================================
+ Hits         7397     9635     +2238     
+ Misses      10503     8265     -2238     
Flag Coverage Δ
macos-14 37.26% <ø> (ø)
ubuntu-latest 56.19% <ø> (+13.14%) ⬆️
windows-2019 37.18% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fgimian fgimian force-pushed the allow_generate_customization_via_env branch from 527646b to 16e678b Compare January 7, 2025 09:32
@ClementTsang ClementTsang self-assigned this Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants