Skip to content

Commit

Permalink
Add upgrade command (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ytkg authored May 3, 2023
1 parent 0dd4ed3 commit 61749e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Install
```bash
$ deno install --allow-env --allow-run --allow-net https://deno.land/x/commit_genius/cg.ts
$ deno install --allow-env --allow-run --allow-net --allow-read https://deno.land/x/commit_genius/cg.ts
✅ Successfully installed cg

$ cg --version
Expand Down
19 changes: 17 additions & 2 deletions commands/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { Command, EnumType, ValidationError } from "../deps.ts";
import {
Command,
DenoLandProvider,
EnumType,
UpgradeCommand,
ValidationError,
} from "../deps.ts";
import { getDiffText } from "../lib/get_diff_text.ts";
import { getCommitMessageSuggestion } from "../lib/get_commit_message_suggestion.ts";

Expand Down Expand Up @@ -32,6 +38,15 @@ export class MainCommand extends Command {
);

console.log(commitMessageSuggestion);
});
})
.command(
"upgrade",
new UpgradeCommand({
main: "cg.ts",
args: ["--allow-env", "--allow-run", "--allow-net", "--allow-read"],
provider: new DenoLandProvider({ name: "commit_genius" }),
}),
)
.reset();
}
}
4 changes: 4 additions & 0 deletions commands/main_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Deno.test("help command", () => {
-m, --model <model> - Model Type (Default: "gpt-3.5-turbo", Values: "gpt-3.5-turbo", "gpt-4")
Commands:
upgrade - Upgrade cg executable to latest or given version.
Environment variables:
OPENAI_ACCESS_TOKEN <value> - OPENAI ACCESS TOKEN
Expand Down
4 changes: 4 additions & 0 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ export {
EnumType,
ValidationError,
} from "https://deno.land/x/[email protected]/command/mod.ts";
export {
DenoLandProvider,
UpgradeCommand,
} from "https://deno.land/x/[email protected]/command/upgrade/mod.ts";
export { OpenAI } from "https://deno.land/x/[email protected]/mod.ts";

0 comments on commit 61749e2

Please sign in to comment.