Fetch User Keys - simple tool for fetching SSH keys from various sources

ft: add SSH authorized_keys output format

hauleth.dev 35153a51 bdd4cf14

verified
Changed files
+18 -3
cli
src
output
docs
+16 -1
cli/src/output/mod.rs
···
JSON,
TOML,
CSV,
}
impl Format {
···
writeln!(w, "")
}
Format::TOML => write!(w, "{}", toml::to_string_pretty(&output.keys).unwrap()),
-
Format::CSV => as_csv(w, &output),
}
}
}
···
Format::JSON => f.write_str("json"),
Format::TOML => f.write_str("toml"),
Format::CSV => f.write_str("csv"),
}
}
}
···
"json" => Format::JSON,
"toml" => Format::TOML,
"csv" => Format::CSV,
_ => unreachable!(),
}
}
···
Ok(())
}
···
JSON,
TOML,
CSV,
+
SSH,
}
impl Format {
···
writeln!(w, "")
}
Format::TOML => write!(w, "{}", toml::to_string_pretty(&output.keys).unwrap()),
+
Format::CSV => as_csv(w, output),
+
Format::SSH => authorized_keys(w, output),
}
}
}
···
Format::JSON => f.write_str("json"),
Format::TOML => f.write_str("toml"),
Format::CSV => f.write_str("csv"),
+
Format::SSH => f.write_str("ssh"),
}
}
}
···
"json" => Format::JSON,
"toml" => Format::TOML,
"csv" => Format::CSV,
+
"ssh" => Format::SSH,
_ => unreachable!(),
}
}
···
Ok(())
}
+
+
fn authorized_keys<W: Write>(w: &mut W, output: &Output) -> io::Result<()> {
+
for (name, keys) in &output.keys {
+
for key in keys {
+
let commented = ssh_key::PublicKey::new(key.key_data().clone(), name);
+
writeln!(w, "{}", commented.to_string())?;
+
}
+
}
+
+
Ok(())
+
}
+2 -2
docs/fuk.1.scd
···
*fuk* -h++
*fuk* --help++
-
*fuk* [--format (json|toml|csv)] _config.toml_
# DESCRIPTION
···
equality. If comments for duplicated keys are different, then there is no
guarantee about comment content.
-
Possible formats - JSON, TOML, CSV.
Example output:
···
*fuk* -h++
*fuk* --help++
+
*fuk* [--format (json|toml|csv|ssh)] _config.toml_
# DESCRIPTION
···
equality. If comments for duplicated keys are different, then there is no
guarantee about comment content.
+
Possible formats - JSON, TOML, CSV, SSH authorized_keys.
Example output: