More reorg, ready to start adding more commands

This commit is contained in:
JP Stringham
2026-03-06 17:01:50 -05:00
parent 2d3bcf3411
commit 9c32cb6245
2 changed files with 28 additions and 53 deletions

View File

@@ -32,7 +32,6 @@ fn main() {
print!("\x1B[2J\x1B[2;5H");
println!("{}", "Welcome to auth tools CLI".bright_cyan());
println!("{} {MATRIX_SERVER_BASE_URL}\n\n", "Homeserver:".green());
print_menu();
let mut app = App::new(MATRIX_SERVER_BASE_URL, MAS_SERVER_BASE_URL);
app.get_auth_metadata();
@@ -40,6 +39,8 @@ fn main() {
app.print_status();
print_menu();
loop {
let input = readline().unwrap();
let input = input.trim();
@@ -61,68 +62,31 @@ fn main() {
match cli.command {
Commands::Setup(sub_args) => {
println!("subargs: {:?}", sub_args);
match sub_args.command {
SetupCommands::GetAuthMetadata => app.get_auth_metadata(),
SetupCommands::RegisterClient => app.register_client(),
SetupCommands::AuthorizeDevice => app.authorize_device(),
SetupCommands::RefreshAuth => app.refresh_auth(),
}
continue;
}
_ => {
if !app.admin_api_ready() {
println!(
"{}",
"Admin API not ready; please use setup subcommand first".red()
);
continue;
}
}
}
match cli.command {
Commands::Setup(_) => unreachable!("Blocked by above match"),
Commands::ShowOauthLinks => app.show_oauth_links(),
}
}
//
// todo!("nope");
// let req = client
// .post(format!(
// "{base_url}{USERS_ENDPT}/01KJXZRB1FSNNQ22DDC0368V9G/deactivate"
// ))
// .header("Accept", "application/json")
// .header("Authorization", access_token)
// .header("Content-Type", "application/json")
// .body(include_str!("../deactivate.json"));
// let req = client
// .post(format!("{base_url}{REGISTRATION_TOKENS_ENDPOINT}/new"))
// .header("Authorization", format!("Bearer {access_token}"))
// .body("{}");
// let req = client.get(format!("{base_url}{USERS_ENDPOINT_V3}")).header(
// "Authorization",
// "Bearer syt_anA_YRbjQUlvKVDuAfIDIdPW_0k2VVC",
// );
// let req = client
// .put(format!(
// "{base_url}{USERS_ENDPOINT_V2}/@afriend:supersaturn.space"
// ))
// .header("Authorization", "))
// .body(include_str!("../postbody.json"));
// println!("{:?}", req);
// let req = req.send().unwrap();
// match req.status() {
// StatusCode::OK | StatusCode::NO_CONTENT | StatusCode::CREATED => (),
// StatusCode::UNAUTHORIZED => {
// if !req.text().unwrap().contains("token expired") {
// panic!("Not authorized: {}", req.text().unwrap());
// }
// let req = client.get(format!("{MAS_SERVER_BASE_URL}{TOKEN_ENDPT}"));
// }
// sc => panic!("Bad response?\n{}\n{:?}", sc, req.text()),
// };
// let req_txt = req.text().unwrap();
// // println!("{}", &req_txt);
// let txt = prettify_json_str(&req_txt);
// println!("Blocking req status\n\n{}\n\n", txt.unwrap());
//
}
const MENU_HELP_TEMPLATE: &str = "\