Skip to content

Commit ea6116d

Browse files
committed
make hooks messages configurable
...and update them to reflect current usage why: - these messages appeared to be just wrong (referencing `aide` instead of firstaide or an `update` command that doesn't appear to exist) - and in any case it's nice to have them all customizeable not just the getting_started message. based on the presence of the `Messages` struct I presume this was always intended how: - add fields to `Messages` struct, named based on the hook they are associated with - set sensible defaults for messages - use serde default attributes to allow mixing defaults and custom messages without errors - add messages to the hooks scripts - splat configured messages into hooks scripts based on how it was done for the getting_started message docs: updated the readme to document messages configuration validation: tested new message configurations in a different project, `cargo test`
1 parent cca838c commit ea6116d

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/config.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,33 @@ impl AsRef<Path> for ParentDir {
5151

5252
#[derive(Debug, Deserialize)]
5353
pub struct Messages {
54+
#[serde(default = "default_getting_started")]
5455
pub getting_started: String,
56+
#[serde(default = "default_stale")]
5557
pub stale: String,
58+
#[serde(default = "default_inactive")]
5659
pub inactive: String,
5760
}
58-
5961
impl Default for Messages {
6062
fn default() -> Self {
6163
Self {
62-
getting_started: "firstaide --help".into(),
63-
stale: "firstaide build".into(),
64-
inactive: "build firstaide and run \"firstaide build\"".into(),
64+
getting_started: default_getting_started(),
65+
stale: default_stale(),
66+
inactive: default_inactive(),
6567
}
6668
}
6769
}
6870

71+
fn default_getting_started() -> String {
72+
"firstaide --help".to_string()
73+
}
74+
fn default_stale() -> String {
75+
"firstaide build".to_string()
76+
}
77+
fn default_inactive() -> String {
78+
"build firstaide and run \"firstaide build\"".to_string()
79+
}
80+
6981
impl Config {
7082
pub fn load<T: Into<PathBuf>>(dir: Option<T>) -> Result<Config> {
7183
let dir = match dir {

0 commit comments

Comments
 (0)