-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1b5a25
commit c438c95
Showing
8 changed files
with
204 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/target | ||
/completions | ||
/man |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
# Changelog | ||
|
||
# [0.1.0] - 2022-07-09 | ||
## [0.2.0] - 2022-08-03 | ||
|
||
### Added | ||
|
||
- `directory` CLI option to specify output CSV file directory. | ||
- `format` CLI option to specify output CSV filename format. | ||
- `quiet` CLI option to mute standard output. | ||
- `csv` CLI option to enable CSV file output at launch. | ||
- Signal handler listening for `SIGUSR1` signals to toggle (*enable*/*disable*) | ||
CSV file output at runtime (e.g. `pkill --signal=SIGUSR1 datalogger`). | ||
- [build.rs](build.rs) build script to generate manpage & shell completions. | ||
- [Makefile](Makefile) to compile/install/uninstall `datalogger` alongside | ||
manpage & shell completions. | ||
|
||
## [0.1.0] - 2022-07-09 | ||
|
||
Initial release. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Paths. | ||
PREFIX = /usr/local | ||
MANPREFIX = ${PREFIX}/share/man | ||
COMPPREFIX = /usr/share | ||
|
||
all: | ||
# Compile & generate manpage and completions for Bash, Fish, Zsh. | ||
cargo build --release | ||
|
||
install: | ||
# Install binary. | ||
mkdir -p ${DESTDIR}${PREFIX}/bin | ||
setcap 'cap_sys_nice=eip' target/release/datalogger | ||
install -Dm 755 target/release/datalogger -t "${DESTDIR}${PREFIX}/bin" | ||
# Install manpage. | ||
mkdir -p ${DESTDIR}${MANPREFIX}/man1 | ||
install -Dm 644 man/datalogger.1 -t "${DESTDIR}${MANPREFIX}/man1" | ||
# Install shell completions. | ||
mkdir -p ${COMPPREFIX}/bash-completion/completions\ | ||
${COMPPREFIX}/zsh/site_functions\ | ||
${COMPPREFIX}/fish/vendor_completions.d | ||
install -Dm 644 completions/datalogger.bash -t "${COMPPREFIX}/bash-completion/completions" | ||
install -Dm 644 completions/_datalogger -t "${COMPPREFIX}/zsh/site-functions" | ||
install -Dm 644 completions/datalogger.fish -t "${COMPPREFIX}/fish/vendor_completions.d" | ||
|
||
uninstall: | ||
rm -f ${DESTDIR}${PREFIX}/bin/datalogger\ | ||
${DESTDIR}${MANPREFIX}/man1/datalogger.1\ | ||
${COMPPREFIX}/bash-completion/completions/datalogger.bash\ | ||
${COMPPREFIX}/zsh/site-functions/_datalogger\ | ||
${COMPPREFIX}/fish/vendor_completions.d/datalogger.fish | ||
|
||
clean: | ||
cargo clean | ||
rm -rf completions man | ||
|
||
.PHONY: all install uninstall clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use clap::CommandFactory; | ||
use clap_complete::{generate_to, Shell::*}; | ||
use clap_mangen::{self, Man}; | ||
use std::env; | ||
|
||
// Include Args struct. | ||
include!("src/args.rs"); | ||
|
||
fn main() { | ||
// Generate man & completions directories. | ||
let manifest_dir = | ||
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("unable to determine manifest dir")); | ||
let man_dir = manifest_dir.join("man"); | ||
let comp_dir = manifest_dir.join("completions"); | ||
|
||
fs::create_dir_all(&man_dir).expect("unable to create man directory"); | ||
fs::create_dir_all(&comp_dir).expect("unable to create completions directory"); | ||
|
||
// Retrieve Args and set binary name. | ||
let mut cmd = Args::command(); | ||
cmd.set_bin_name("datalogger"); | ||
|
||
// Generate & write man page. | ||
let mut buffer: Vec<u8> = Vec::new(); | ||
Man::new(cmd.clone()) | ||
.render(&mut buffer) | ||
.expect("unable to generate man page"); | ||
fs::write(man_dir.join("datalogger.1"), buffer).expect("unable to write man page"); | ||
|
||
// Generate shell completions. | ||
for shell in [Bash, Fish, Zsh] { | ||
generate_to(shell, &mut cmd, "datalogger", &comp_dir) | ||
.expect("unable to generate completions"); | ||
} | ||
} |