Skip to content

Commit b8558ff

Browse files
fix: add options to yargs along with examples (#27)
1 parent 0bf6820 commit b8558ff

File tree

3 files changed

+67
-13
lines changed

3 files changed

+67
-13
lines changed

bin/github-default-branch

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
#!/usr/bin/env node
22
(async function () {
3-
const { argv } = require("yargs");
3+
const { argv } = require("yargs").options({
4+
pat: {type: "string", description: "GitHub API Token"},
5+
repo: {type: "string", description: "The repo to update (format: user/repo"},
6+
user: {type: "string", description: "Update all repos owned by the provided user (example: my-user)"},
7+
org: {type: "string", description: "Update all repos in the provided org (example: my-org-name)"},
8+
keepOld: {type: "boolean", default: false, description: "Keep the old branch rather than deleting it"},
9+
dryRun: {type: "boolean", default: false, description: "Output log messages only. Do not make any changes"},
10+
listReposOnly: {type: "boolean", default: false, description: "List repos that would be affected, then exit"},
11+
skipForks: {type: "boolean", default: false, description: "Skips forked repositories"},
12+
old: {type: "string", default: "master", description: "The name of the branch to rename"},
13+
new: {type: "string", default: "main", description: "The new branch name"},
14+
confirm: {type: "boolean", default: false, description: "Run without prompting for confirmation"},
15+
}).example([
16+
["$0 --pat <token> --repo user/repo", "Rename master to main"],
17+
["$0 --pat <token> --repo user/repo --old dev --new develop", "Rename dev to develop"],
18+
["$0 --pat <token> --org my-org-name", "Rename all repos owned by an org"],
19+
["$0 --pat <token> --user my-user", "Rename all repos owned by a user"],
20+
]);
421

522
const isDryRun = !!argv.dryRun;
623

package-lock.json

Lines changed: 48 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@octokit/rest": "^18.0.0",
2121
"prompt-confirm": "^2.0.4",
2222
"string.prototype.replaceall": "^1.0.3",
23-
"yargs": "^15.3.1"
23+
"yargs": "^15.4.0"
2424
},
2525
"bin": {
2626
"github-default-branch": "./bin/github-default-branch"

0 commit comments

Comments
 (0)