-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Onboarding flow improvements (#265)
Makes some small improvements to the onboarding flow - **Remove owner/repo name detection and make auto push to remote false by default** - **Add a header for the llm part** - **Remove all panics when onboarding**
- Loading branch information
Showing
7 changed files
with
83 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,41 @@ | ||
use anyhow::Result; | ||
use serde_json::json; | ||
|
||
use crate::{ | ||
config::defaults::{default_main_branch, default_owner_and_repo}, | ||
onboarding::util::{prompt_api_key, prompt_text}, | ||
}; | ||
|
||
pub fn git_questions(context: &mut tera::Context) { | ||
pub fn git_questions(context: &mut tera::Context) -> Result<()> { | ||
let (default_owner, default_repository) = default_owner_and_repo().unzip(); | ||
let default_branch = default_main_branch(); | ||
let branch_input = prompt_text("Default git branch", Some(&default_branch)) | ||
.prompt() | ||
.unwrap(); | ||
|
||
println!("\nWith a github token, Kwaak can create pull requests, search github code, and automatically push to the remote."); | ||
let github_api_key = prompt_api_key( | ||
"GitHub api key (optional, <esc> to skip)", | ||
Some("env:GITHUB_TOKEN"), | ||
) | ||
.prompt_skippable() | ||
.unwrap(); | ||
|
||
let auto_push_remote = | ||
let branch_input = prompt_text("Default git branch", Some(&default_branch)).prompt()?; | ||
|
||
println!("\nWith a github token, Kwaak can create pull requests, search github code, and automatically push to the remote. Kwaak will never push to the main branch."); | ||
|
||
let github_api_key = prompt_api_key("Github token (optional, <esc> to skip)", None) | ||
.with_placeholder("env:GITHUB_token") | ||
.prompt_skippable()?; | ||
|
||
let auto_push_remote = if github_api_key.is_some() { | ||
inquire::Confirm::new("Push to git remote after changes? (requires github token)") | ||
.with_default(github_api_key.is_some()) | ||
.prompt() | ||
.unwrap(); | ||
|
||
let owner_input = prompt_text( | ||
"Git owner (optional, <esc> to skip)", | ||
default_owner.as_deref(), | ||
) | ||
.prompt_skippable() | ||
.unwrap(); | ||
let repository_input = prompt_text( | ||
"Git repository (optional, <esc> to skip)", | ||
default_repository.as_deref(), | ||
) | ||
.prompt_skippable() | ||
.unwrap(); | ||
.with_default(false) | ||
.prompt()? | ||
} else { | ||
false | ||
}; | ||
|
||
context.insert("github_api_key", &github_api_key); | ||
context.insert( | ||
"git", | ||
&json!({ | ||
"owner": owner_input, | ||
"repository": repository_input, | ||
"owner": default_owner, | ||
"repository": default_repository, | ||
"main_branch": branch_input, | ||
"auto_push_remote": auto_push_remote, | ||
|
||
}), | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.