Compare commits

..

No commits in common. "a6b5171ad8bf7785d3bb67c870852a9dbd095965" and "fa1e646f012814f60bea460ed3bde8067790792d" have entirely different histories.

2 changed files with 12 additions and 11 deletions

View File

@ -1,4 +1,2 @@
# To-do
- Report that "ReadableConfig" error, which was super unhelpful and very annoying when you don't know why it's bugging.
- Find a better notation for the error-handling in setup() although the custom error message is desirable, it's very bad
to have to implement it using such a ridiculously long line...
- Report that "ReadableConfig" error, which was super unhelpful and very annoying when you don't know why it's bugging.

View File

@ -42,15 +42,18 @@ enum Action {
}
fn setup(args: SetupArgs) -> Result<(), std::io::Error> {
let config_template = std::fs::read_to_string(CONFIG_TEMPLATE_PATH).or(Err(std::io::Error::new(std::io::ErrorKind::NotFound, format!("Unable to find {}; did you execute the script from the same directory?", CONFIG_TEMPLATE_PATH))))?;
let filled_in_config = formatx!(config_template, args.api_url, args.rest_url, args.username, args.botpassword, args.oauth2_token).unwrap();
let path = shellexpand::tilde(BOT_CONFIG_PATH).into_owned();
std::fs::write(&path, filled_in_config).unwrap();
{
use std::os::unix::fs::PermissionsExt;
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600))?;
if let Ok(config_template) = std::fs::read_to_string(CONFIG_TEMPLATE_PATH) {
let filled_in_config = formatx!(config_template, args.api_url, args.rest_url, args.username, args.botpassword, args.oauth2_token).unwrap();
let path = shellexpand::tilde(BOT_CONFIG_PATH).into_owned();
std::fs::write(&path, filled_in_config).unwrap();
{
use std::os::unix::fs::PermissionsExt;
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600))?;
}
Ok(())
} else {
Err(std::io::Error::new(std::io::ErrorKind::NotFound, format!("Unable to find {}; did you execute the script from the same directory?", CONFIG_TEMPLATE_PATH)))
}
Ok(())
}
#[tokio::main]