Skip to content

Commit d181107

Browse files
committed
🎨 Add --no-ai flag to commit without using GPT-3
This commit adds a new flag, "--no-ai" or "-n", which allows users to commit changes without using GPT-3. This is useful for cases where GPT-3 is not needed or desired.
1 parent 62672bd commit d181107

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Options:
2727
--update, -u: Updates the program to the latest version.
2828
--force-update, -f: Forces the update to the latest version.
2929
--init, -i: Initializes a README.md file in the current directory based on the content of the given files.
30+
--no-ai, -n: Commits the changes without using GPT-3.
3031
--push, -p: Pushes the changes to the remote repository after running the commands.
3132
--api-key: Sets the API key to use for GPT-3. You can also set the API key in the .env file.
3233
--clear-api-key: Clears the API key from the config file.

‎src/main.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ async fn main() {
6363
"--init, -i [files]:".magenta(),
6464
"Initializes a README.md file in the current directory based on the content of the given files"
6565
);
66+
println!(
67+
"{} {}",
68+
"--no-ai, -n:".magenta(),
69+
"Commits the changes without using GPT-3"
70+
);
6671
println!(
6772
"{} {}",
6873
"--push, -p:".magenta(),
@@ -234,6 +239,12 @@ async fn main() {
234239
std::process::exit(0);
235240
}
236241

242+
if args.contains(&"--no-ai".to_owned()) || args.contains(&"-n".to_owned()) {
243+
let result = vec!["#Title", "##Body"].join("\n");
244+
run(&args, result, push, &git);
245+
return;
246+
}
247+
237248
let loader = utils::Loader::new("Waiting for response from GPT-3");
238249

239250
let result = query(None, &git, args.clone()).await;
@@ -367,5 +378,10 @@ fn edit(result: String) -> String {
367378

368379
lines[index] = prompt.as_str();
369380

370-
lines.join("\n")
381+
lines
382+
.iter()
383+
.filter(|line| !line.is_empty())
384+
.map(|line| line.to_owned())
385+
.collect::<Vec<&str>>()
386+
.join("\n")
371387
}

0 commit comments

Comments
 (0)