use crate::define_tool;
define_tool!(GLANCES, {
command: "glances",
macos: { brew: "glances" },
linux: { uniform: "glances" },
bsd: { pkg: "py-glances" },
default_hook: {
description: "Seed ~/.config/glances/glances.conf with CSV history export to ~/.jarvy/glances/",
script: r#"
# Seed a minimal glances.conf that turns on CSV export so usage history persists.
# Idempotent: only writes if the file does not already exist (user edits win).
CONF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/glances"
CONF_FILE="$CONF_DIR/glances.conf"
HIST_DIR="$HOME/.jarvy/glances"
HIST_FILE="$HIST_DIR/history.csv"
mkdir -p "$CONF_DIR" "$HIST_DIR"
if [ ! -f "$CONF_FILE" ]; then
cat > "$CONF_FILE" <<EOF
# Generated by jarvy. Safe to edit; jarvy will not overwrite an existing file.
# Run with: glances --export csv
# Or persistently via a systemd/launchd unit you own.
[csv]
file=$HIST_FILE
EOF
echo "Wrote glances config: $CONF_FILE"
echo "Run 'glances --export csv' to begin recording to $HIST_FILE"
else
echo "glances config already exists at $CONF_FILE (left untouched)"
fi
"#
},
});
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn glances_registration_shape() {
assert_eq!(GLANCES.command, "glances");
let mac = GLANCES.macos.expect("must support macOS");
assert_eq!(mac.brew, Some("glances"));
let linux = GLANCES.linux.expect("must support Linux");
assert_eq!(linux.apt, Some("glances"));
assert!(GLANCES.windows.is_none(), "no first-party winget manifest");
assert!(GLANCES.has_default_hook());
}
}