Skip to content

Commit

Permalink
fix: add options to yargs along with examples (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisonmuskat authored Jul 8, 2020
1 parent 0bf6820 commit b8558ff
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 13 deletions.
19 changes: 18 additions & 1 deletion bin/github-default-branch
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
#!/usr/bin/env node
(async function () {
const { argv } = require("yargs");
const { argv } = require("yargs").options({
pat: {type: "string", description: "GitHub API Token"},
repo: {type: "string", description: "The repo to update (format: user/repo"},
user: {type: "string", description: "Update all repos owned by the provided user (example: my-user)"},
org: {type: "string", description: "Update all repos in the provided org (example: my-org-name)"},
keepOld: {type: "boolean", default: false, description: "Keep the old branch rather than deleting it"},
dryRun: {type: "boolean", default: false, description: "Output log messages only. Do not make any changes"},
listReposOnly: {type: "boolean", default: false, description: "List repos that would be affected, then exit"},
skipForks: {type: "boolean", default: false, description: "Skips forked repositories"},
old: {type: "string", default: "master", description: "The name of the branch to rename"},
new: {type: "string", default: "main", description: "The new branch name"},
confirm: {type: "boolean", default: false, description: "Run without prompting for confirmation"},
}).example([
["$0 --pat <token> --repo user/repo", "Rename master to main"],
["$0 --pat <token> --repo user/repo --old dev --new develop", "Rename dev to develop"],
["$0 --pat <token> --org my-org-name", "Rename all repos owned by an org"],
["$0 --pat <token> --user my-user", "Rename all repos owned by a user"],
]);

const isDryRun = !!argv.dryRun;

Expand Down
59 changes: 48 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@octokit/rest": "^18.0.0",
"prompt-confirm": "^2.0.4",
"string.prototype.replaceall": "^1.0.3",
"yargs": "^15.3.1"
"yargs": "^15.4.0"
},
"bin": {
"github-default-branch": "./bin/github-default-branch"
Expand Down

0 comments on commit b8558ff

Please sign in to comment.