Compare commits
No commits in common. "fa1e646f012814f60bea460ed3bde8067790792d" and "a15b23a70a2d20204b829d20028e52b4fed74189" have entirely different histories.
fa1e646f01
...
a15b23a70a
2
TODO.md
2
TODO.md
@ -1,2 +0,0 @@
|
|||||||
# To-do
|
|
||||||
- Report that "ReadableConfig" error, which was super unhelpful and very annoying when you don't know why it's bugging.
|
|
@ -4,5 +4,5 @@ rest_url = "{}"
|
|||||||
|
|
||||||
[auth]
|
[auth]
|
||||||
username = "{}"
|
username = "{}"
|
||||||
password = "{}"
|
botpassword = "{}"
|
||||||
# oauth2_token = "{}"
|
oauth2_token = "{}"
|
12
src/main.rs
12
src/main.rs
@ -2,7 +2,6 @@ use formatx::formatx;
|
|||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use mwbot::parsoid::WikiMultinode;
|
use mwbot::parsoid::WikiMultinode;
|
||||||
|
|
||||||
const CONFIG_TEMPLATE_PATH: &'static str = "mwbot_template.toml";
|
|
||||||
const BOT_CONFIG_PATH: &'static str = "~/.config/mwbot.toml";
|
const BOT_CONFIG_PATH: &'static str = "~/.config/mwbot.toml";
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
@ -42,17 +41,12 @@ enum Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup(args: SetupArgs) -> Result<(), std::io::Error> {
|
fn setup(args: SetupArgs) -> Result<(), std::io::Error> {
|
||||||
if let Ok(config_template) = std::fs::read_to_string(CONFIG_TEMPLATE_PATH) {
|
if let Ok(config_template) = std::fs::read_to_string("mwbot.toml") {
|
||||||
let filled_in_config = formatx!(config_template, args.api_url, args.rest_url, args.username, args.botpassword, args.oauth2_token).unwrap();
|
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(shellexpand::tilde(BOT_CONFIG_PATH).into_owned(), filled_in_config).unwrap();
|
||||||
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(())
|
Ok(())
|
||||||
} else {
|
} 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)))
|
Err(std::io::Error::new(std::io::ErrorKind::NotFound, "Unable to find mwbot.toml; did you execute the script from the same directory?"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user