generated from pure_sagacity/rust-starter
added the provider trait, github provider, and a fzf selector.
i forgot to commit :(
This commit is contained in:
+41
-2
@@ -1,3 +1,42 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use crate::{
|
||||
providers::{Provider, github::Github},
|
||||
tui::user_select_repo,
|
||||
};
|
||||
use dialoguer::{Select, theme::ColorfulTheme};
|
||||
mod providers;
|
||||
mod tui;
|
||||
|
||||
pub fn ask_yes_no(message: &str) -> bool {
|
||||
let options = vec!["Yes", "No"];
|
||||
|
||||
let selection = Select::with_theme(&ColorfulTheme::default())
|
||||
.with_prompt(message.to_string())
|
||||
.items(&options)
|
||||
.default(0)
|
||||
.interact()
|
||||
.unwrap();
|
||||
|
||||
match options[selection] {
|
||||
"Yes" => true,
|
||||
"No" => false,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Testing to see if github provider works.
|
||||
let gh = Github {
|
||||
username: "pure-sagacity".to_string(),
|
||||
};
|
||||
|
||||
let repos = gh.repositories().await.expect("Failed to get repos.");
|
||||
|
||||
let selection = user_select_repo(repos)
|
||||
.await
|
||||
.expect("Failed to select repository.");
|
||||
|
||||
println!("{:#?}", selection);
|
||||
|
||||
println!("{}", ask_yes_no("Clone the repo?"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user