other: add manpage file to cargo deb config, move back to build script (#693)
Adds the asset for the manpage to cargo deb config. Also moves the generated manpage file to a .1.gz file. Also, moves back to a build script since that was causing some issues for the automatic Cargo.toml fields detection for manpage and completion generation. To prevent compilation from happening every time, and only in CI, we use an env var to avoid generation steps.
This commit is contained in:
parent
8087f0b636
commit
f2b8b4e842
|
@ -148,15 +148,10 @@ jobs:
|
|||
args: --release --verbose --target=${{ matrix.triple.target }} --features "battery"
|
||||
use-cross: ${{ matrix.triple.cross }}
|
||||
|
||||
- name: Build autocompletion
|
||||
- name: Build autocompletion and manpage
|
||||
shell: bash
|
||||
run: |
|
||||
cargo run --manifest-path ./xtask/Cargo.toml -- completion completion
|
||||
|
||||
- name: Build manpage
|
||||
shell: bash
|
||||
run: |
|
||||
cargo run --manifest-path ./xtask/Cargo.toml -- manpage manpage
|
||||
GENERATE=true cargo build
|
||||
|
||||
- name: Bundle release and completion (Windows)
|
||||
if: matrix.triple.os == 'windows-2019'
|
||||
|
@ -192,6 +187,7 @@ jobs:
|
|||
if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == ''
|
||||
shell: bash
|
||||
run: |
|
||||
gzip ./manpage/btm.1
|
||||
tar -C ./manpage -czvf manpage.tar.gz .
|
||||
mv manpage.tar.gz release/
|
||||
|
||||
|
@ -319,11 +315,11 @@ jobs:
|
|||
command: build
|
||||
args: --release --verbose --features "battery"
|
||||
|
||||
- name: Move autocomplete to working directory
|
||||
- name: Build autocompletion and manpage
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir completion
|
||||
cp -r ./target/release/build/bottom-*/out/. completion
|
||||
GENERATE=true cargo build
|
||||
gzip ./manpage/btm.1
|
||||
|
||||
- name: Build Debian release
|
||||
run: |
|
||||
|
|
|
@ -144,15 +144,10 @@ jobs:
|
|||
args: --release --verbose --target=${{ matrix.triple.target }} --features "battery"
|
||||
use-cross: ${{ matrix.triple.cross }}
|
||||
|
||||
- name: Build autocompletion
|
||||
- name: Build autocompletion and manpage
|
||||
shell: bash
|
||||
run: |
|
||||
cargo run --manifest-path ./xtask/Cargo.toml -- completion completion
|
||||
|
||||
- name: Build manpage
|
||||
shell: bash
|
||||
run: |
|
||||
cargo run --manifest-path ./xtask/Cargo.toml -- manpage manpage
|
||||
GENERATE=true cargo build
|
||||
|
||||
- name: Bundle release and completion (Windows)
|
||||
if: matrix.triple.os == 'windows-2019'
|
||||
|
@ -188,6 +183,7 @@ jobs:
|
|||
if: matrix.triple.target == 'x86_64-unknown-linux-gnu' && matrix.triple.container == ''
|
||||
shell: bash
|
||||
run: |
|
||||
gzip ./manpage/btm.1
|
||||
tar -C ./manpage -czvf manpage.tar.gz .
|
||||
mv manpage.tar.gz release/
|
||||
|
||||
|
@ -313,11 +309,11 @@ jobs:
|
|||
command: build
|
||||
args: --release --verbose --features "battery"
|
||||
|
||||
- name: Move autocomplete to working directory
|
||||
- name: Build autocompletion and manpage
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir completion
|
||||
cp -r ./target/release/build/bottom-*/out/. completion
|
||||
GENERATE=true cargo build
|
||||
gzip ./manpage/btm.1
|
||||
|
||||
- name: Build Debian release
|
||||
run: |
|
||||
|
|
|
@ -230,6 +230,8 @@ dependencies = [
|
|||
"cargo-husky",
|
||||
"cfg-if",
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"clap_mangen",
|
||||
"crossterm",
|
||||
"ctrlc",
|
||||
"dirs",
|
||||
|
@ -324,6 +326,25 @@ dependencies = [
|
|||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "3.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df6f3613c0a3cddfd78b41b10203eb322cb29b600cbdf808a7d3db95691b8e25"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_mangen"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0649fb4156bbd7306896025005596033879a2051f9a3aa7416ab915df1f8fdac"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"roff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "concurrent-queue"
|
||||
version = "1.2.2"
|
||||
|
@ -1318,6 +1339,12 @@ version = "0.6.25"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
|
||||
|
||||
[[package]]
|
||||
name = "roff"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.21"
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -11,6 +11,7 @@ description = "A customizable cross-platform graphical process/system monitor fo
|
|||
documentation = "https://clementtsang.github.io/bottom/stable"
|
||||
readme = "README.md"
|
||||
default-run = "btm"
|
||||
build = "build.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "btm"
|
||||
|
@ -83,6 +84,10 @@ winapi = "0.3.9"
|
|||
assert_cmd = "2.0"
|
||||
predicates = "2.1"
|
||||
|
||||
[build-dependencies]
|
||||
clap = { version = "3.1.6", features = ["default", "cargo", "wrap_help"] }
|
||||
clap_complete = "3.1.1"
|
||||
clap_mangen = "0.1.2"
|
||||
|
||||
[package.metadata.deb]
|
||||
section = "utility"
|
||||
|
@ -97,6 +102,11 @@ assets = [
|
|||
"usr/share/doc/btm/",
|
||||
"644",
|
||||
],
|
||||
[
|
||||
"manpage/btm.1.gz",
|
||||
"usr/share/man/man1/btm.1.gz",
|
||||
"644",
|
||||
],
|
||||
[
|
||||
"completion/btm.bash",
|
||||
"usr/share/bash-completion/completions/btm",
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
use clap_complete::{generate_to, shells::Shell};
|
||||
use std::{
|
||||
env, fs,
|
||||
io::Result,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
include!("src/clap.rs");
|
||||
|
||||
fn create_dir(dir: &Path) -> Result<()> {
|
||||
let res = fs::create_dir_all(&dir);
|
||||
match &res {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
eprintln!(
|
||||
"Failed to create a directory at location {:?}, encountered error {:?}. Aborting...",
|
||||
dir, err
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
if env::var_os("GENERATE").is_some() {
|
||||
// OUT_DIR is where extra build files are written to for Cargo.
|
||||
let completion_out_dir = PathBuf::from("completion");
|
||||
let manpage_out_dir = PathBuf::from("manpage");
|
||||
|
||||
create_dir(&completion_out_dir)?;
|
||||
create_dir(&manpage_out_dir)?;
|
||||
|
||||
// Generate completions
|
||||
let mut app = build_app();
|
||||
generate_to(Shell::Bash, &mut app, "btm", &completion_out_dir)?;
|
||||
generate_to(Shell::Zsh, &mut app, "btm", &completion_out_dir)?;
|
||||
generate_to(Shell::Fish, &mut app, "btm", &completion_out_dir)?;
|
||||
generate_to(Shell::PowerShell, &mut app, "btm", &completion_out_dir)?;
|
||||
generate_to(Shell::Elvish, &mut app, "btm", &completion_out_dir)?;
|
||||
|
||||
// Generate manpage
|
||||
let app = app.name("btm");
|
||||
let man = clap_mangen::Man::new(app);
|
||||
let mut buffer: Vec<u8> = Default::default();
|
||||
man.render(&mut buffer)?;
|
||||
std::fs::write(manpage_out_dir.join("btm.1"), buffer)?;
|
||||
}
|
||||
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=./src/clap.rs");
|
||||
println!("cargo:rerun-if-env-changed=GENERATE");
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -225,6 +225,7 @@ pub fn build_app() -> Command<'static> {
|
|||
If it doesn't exist, one is created.",
|
||||
);
|
||||
|
||||
// TODO: Fix this, its broken in the manpage
|
||||
let color = Arg::new("color")
|
||||
.long("color")
|
||||
.takes_value(true)
|
||||
|
@ -274,6 +275,7 @@ Defaults to \"default\".
|
|||
.help("Default time value for graphs in ms.")
|
||||
.long_help("Default time value for graphs in milliseconds. The minimum time is 30s (30000), and the default is 60s (60000).");
|
||||
|
||||
// TODO: Fix this, its broken in the manpage
|
||||
let default_widget_count = Arg::new("default_widget_count")
|
||||
.long("default_widget_count")
|
||||
.takes_value(true)
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# Logging
|
||||
*.log
|
||||
|
||||
# Flamegraph stuff
|
||||
rust-unmangle
|
||||
*.svg
|
||||
*.data
|
||||
*.data.old
|
||||
|
||||
# IntelliJ
|
||||
.idea/
|
||||
|
||||
# Heaptrack files
|
||||
*.zst
|
||||
|
||||
# For testing
|
||||
sample_configs/testing.toml
|
||||
|
||||
# Wix
|
||||
/wix/
|
||||
|
||||
# Cargo-deny
|
||||
deny.toml
|
||||
|
||||
# vscode
|
||||
.vscode
|
||||
|
||||
# mkdocs
|
||||
site/
|
||||
docs/site
|
|
@ -1,194 +0,0 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"os_str_bytes",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"terminal_size",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "3.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df6f3613c0a3cddfd78b41b10203eb322cb29b600cbdf808a7d3db95691b8e25"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_mangen"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0649fb4156bbd7306896025005596033879a2051f9a3aa7416ab915df1f8fdac"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"roff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.119"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "roff"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
dependencies = [
|
||||
"terminal_size",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "xtask"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"clap_mangen",
|
||||
]
|
|
@ -1,9 +0,0 @@
|
|||
[package]
|
||||
name = "xtask"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "3.1.6", features = ["default", "cargo", "wrap_help"] }
|
||||
clap_complete = "3.1.1"
|
||||
clap_mangen = "0.1.2"
|
|
@ -1,55 +0,0 @@
|
|||
use clap_complete::{generate_to, shells::Shell};
|
||||
use std::{env, fs, io::Result, path::PathBuf, process};
|
||||
|
||||
include!("../../src/clap.rs");
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let command = if let Some(command) = env::args().nth(1) {
|
||||
command
|
||||
} else {
|
||||
eprintln!("A command was not given!");
|
||||
process::exit(1)
|
||||
};
|
||||
|
||||
let out_dir = if let Some(out_dir) = env::args().nth(2) {
|
||||
PathBuf::from(out_dir)
|
||||
} else {
|
||||
eprintln!("An output directory was not set!");
|
||||
process::exit(1)
|
||||
};
|
||||
|
||||
if let Err(err) = fs::create_dir_all(&out_dir) {
|
||||
eprintln!(
|
||||
"Failed to create a directory at the output director location {:?}, encountered error {:?}. Aborting...",
|
||||
out_dir, err
|
||||
);
|
||||
process::exit(1)
|
||||
}
|
||||
|
||||
match command.as_str() {
|
||||
"completion" => {
|
||||
// Generate completions
|
||||
let mut app = build_app();
|
||||
generate_to(Shell::Bash, &mut app, "btm", &out_dir)?;
|
||||
generate_to(Shell::Zsh, &mut app, "btm", &out_dir)?;
|
||||
generate_to(Shell::Fish, &mut app, "btm", &out_dir)?;
|
||||
generate_to(Shell::PowerShell, &mut app, "btm", &out_dir)?;
|
||||
generate_to(Shell::Elvish, &mut app, "btm", &out_dir)?;
|
||||
}
|
||||
"manpage" => {
|
||||
// Generate manpage
|
||||
let app = build_app();
|
||||
let man = clap_mangen::Man::new(app);
|
||||
let mut buffer: Vec<u8> = Default::default();
|
||||
man.render(&mut buffer).unwrap();
|
||||
|
||||
std::fs::write(out_dir.join("btm.1"), buffer)?;
|
||||
}
|
||||
_ => {
|
||||
eprintln!("Invalid command given: `{}`", command);
|
||||
process::exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in New Issue