Skip to content

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

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

Merged
merged 1 commit into from
Jan 18, 2025
Merged

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

merged 1 commit into from
Jan 18, 2025

Conversation

fgimian
Copy link
Contributor

@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).
Report is 4 commits behind head on main.

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.

@ClementTsang ClementTsang self-assigned this Jan 7, 2025
@ClementTsang ClementTsang merged commit cf91c73 into ClementTsang:main Jan 18, 2025
37 checks passed
@ClementTsang
Copy link
Owner

Thanks for this!

@all-contributors please add @fgimian for code, docs.

Copy link
Contributor

@ClementTsang

I've put up a pull request to add @fgimian! 🎉

@fgimian
Copy link
Contributor Author

fgimian commented Jan 18, 2025

Thanks for this!

@all-contributors please add @fgimian for code, docs.

Thanks a lot for the merge! 😊

Copy link
Contributor

@fgimian

@fgimian already contributed before to code, doc

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 6, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [ClementTsang/bottom](https://github.com/ClementTsang/bottom) | minor | `0.10.2` -> `0.11.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>ClementTsang/bottom (ClementTsang/bottom)</summary>

### [`v0.11.0`](https://github.com/ClementTsang/bottom/blob/HEAD/CHANGELOG.md#0110---2025-08-05)

[Compare Source](ClementTsang/bottom@0.10.2...0.11.0)

##### Features

- [#&#8203;1625](ClementTsang/bottom#1625): Add the ability to configure the disk widget's table columns.
- [#&#8203;1641](ClementTsang/bottom#1641) + [#&#8203;1692](ClementTsang/bottom#1692): Support AMD GPU data collection on Linux.
- [#&#8203;1642](ClementTsang/bottom#1642): Support changing the widget borders.
- [#&#8203;1717](ClementTsang/bottom#1717): Support delete key (fn + delete on macOS) to kill processes.
- [#&#8203;1306](ClementTsang/bottom#1306): Support using left/right key to collapse/expand process trees respectively.
- [#&#8203;1767](ClementTsang/bottom#1767): Add a virtual memory column for processes.
- [#&#8203;1770](ClementTsang/bottom#1770) (originally [#&#8203;1627](ClementTsang/bottom#1627)): Add option to have process tree entries be collapsed by default.

##### Bug Fixes

- [#&#8203;1551](ClementTsang/bottom#1551): Fix missing parent section names in default config.
- [#&#8203;1552](ClementTsang/bottom#1552): Fix typo in default config.
- [#&#8203;1565](ClementTsang/bottom#1565): Fix issue where CPU usage in basic mode looks weird if core count isn't divisible by four.
- [#&#8203;1578](ClementTsang/bottom#1578): Fix missing selected text background colour in `default-light` theme.
- [#&#8203;1593](ClementTsang/bottom#1593): Fix using `"none"` for chart legend position in configs.
- [#&#8203;1594](ClementTsang/bottom#1594): Fix incorrect default config definitions for chart legends.
- [#&#8203;1596](ClementTsang/bottom#1596): Fix support for nilfs2 file system.
- [#&#8203;1660](ClementTsang/bottom#1660): Fix properly cleaning up the terminal if the program is terminated due to an `Err` bubbling to the top.
- [#&#8203;1663](ClementTsang/bottom#1663): Fix network graphs using log scaling having broken lines when a point was 0.
- [#&#8203;1667](ClementTsang/bottom#1667): Fix for ARC/SWAP not being hidden in basic mode after refactor.
- [#&#8203;1683](ClementTsang/bottom#1683): Fix graph lines potentially showing up behind legends.
- [#&#8203;1701](ClementTsang/bottom#1701): Fix process kill dialog occasionally causing panics.
- [#&#8203;1755](ClementTsang/bottom#1755): Fix missing stats/incorrect mount name for certain entries in the disk widget.
- [#&#8203;1759](ClementTsang/bottom#1759): Fix increment for data tables if the change is greater than the number of entries left.

##### Changes

- [#&#8203;1559](ClementTsang/bottom#1559): Rename `--enable_gpu` to `--disable_gpu`, and make GPU features enabled by default.
- [#&#8203;1570](ClementTsang/bottom#1570): Consider `$XDG_CONFIG_HOME` on macOS when looking for a default config path in a backwards-compatible fashion.
- [#&#8203;1686](ClementTsang/bottom#1686): Allow hyphenated arguments to work as well (e.g. `--autohide-time`).
- [#&#8203;1701](ClementTsang/bottom#1701): Redesign process kill dialog.
- [#&#8203;1706](ClementTsang/bottom#1706): Disable mouse capture when `disable_click` is set.
- [#&#8203;1769](ClementTsang/bottom#1769): Change how we calculate swap usage in Windows.

##### Other

- [#&#8203;1655](ClementTsang/bottom#1655): Better handle NVIDIA GPUs on Linux with only libnvidia-ml.so.1.
- [#&#8203;1658](ClementTsang/bottom#1658): Make it possible to override completion/manpage generation output directory via env.
- [#&#8203;1663](ClementTsang/bottom#1663): Rework how data is stored internally, reducing memory usage a bit.
- [#&#8203;1749](ClementTsang/bottom#1749): Fix invalid desktop file values.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS41My4xIiwidXBkYXRlZEluVmVyIjoiNDEuNTMuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
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