Skip to content

Commit

Permalink
🔧 user input trumps all;
Browse files Browse the repository at this point in the history
🐛 public func for default checks
  • Loading branch information
dmiller15 committed Jan 31, 2024
1 parent b1d8d35 commit 7b49e89
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/commands/encoder_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn hdr_info_id2description(
HeaderRecord::Info {key: _, values: v} => if v.contains_key("Description") { &v["Description"] } else { default },
_ => default,
};
return description.to_string();
return description.trim_matches('"').to_string();
}

pub fn encoder_main(vpaths: Vec<&str>, opath: &str, jpath: &str) {
Expand Down Expand Up @@ -247,9 +247,8 @@ pub fn encoder_main(vpaths: Vec<&str>, opath: &str, jpath: &str) {
tl, f.field
),
};
let hdr_des = hdr_info_id2description(header.header_records(), &f.field, &f.description);
if f.description == fields::default_description_string() {
f.description = hdr_des;
f.description = hdr_info_id2description(header.header_records(), &f.field, &f.description);
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/echtvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl EchtVars {
for e in &self.fields {
header.push_record(
format!(
"##INFO=<ID={},Number={},Type={},Description={}>",
"##INFO=<ID={},Number={},Type={},Description=\"{}\">",
e.alias,
if vec!["A", "R", "G"].iter().any(|n| n == &e.number) {
"1"
Expand All @@ -191,8 +191,8 @@ impl EchtVars {
} else {
"Float"
},
if &e.description.to_string() == "added by echtvar"{
format!("\"added by echtvar from {}\"", path)
if e.description.to_string() == fields::default_description_string() {
format!("added by echtvar from {}", path)
} else {
format!("added by echtvar {}", e.description.to_string())
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn default_missing_value() -> i32 {
fn default_missing_string() -> std::string::String {
"MISSING".to_string()
}
fn default_description_string() -> std::string::String {
pub fn default_description_string() -> std::string::String {
"added by echtvar".to_string()
}
fn default_multiplier() -> u32 {
Expand Down

0 comments on commit 7b49e89

Please sign in to comment.