80 lines
2.4 KiB
JavaScript
Executable File
80 lines
2.4 KiB
JavaScript
Executable File
const yargs = require("yargs");
|
|
|
|
const newCommand = require("./commands/new");
|
|
const status = require("./commands/status");
|
|
const done = require("./commands/done");
|
|
const upstream = require("./commands/upstream");
|
|
|
|
const utils = require("./utils");
|
|
|
|
module.exports.run = async () => {
|
|
const currentBranch = await utils.currentBranch();
|
|
|
|
return yargs
|
|
.scriptName("git-mikado")
|
|
.showHelpOnFail(true)
|
|
.command("status", "show status of all mikado branches", status)
|
|
.command(
|
|
"done [branch]",
|
|
"set branch as done",
|
|
(yargs) => {
|
|
return yargs.positional("branch", {
|
|
describe: "branch to mark as done",
|
|
default: currentBranch,
|
|
});
|
|
},
|
|
done
|
|
)
|
|
.command(
|
|
"upstream [upstream]",
|
|
"set an upstream of the current branch",
|
|
(yargs) => {
|
|
return yargs
|
|
.positional("upstream", {
|
|
describe: "upstream branch to add",
|
|
})
|
|
.option("branch", {
|
|
alias: "b",
|
|
describe: "target branch",
|
|
default: currentBranch,
|
|
})
|
|
.demandOption(["upstream"]);
|
|
},
|
|
upstream
|
|
)
|
|
.command(
|
|
"new [branch]",
|
|
"create new mikado branch",
|
|
(yargs) => {
|
|
return yargs
|
|
.positional("branch", {
|
|
describe: "name of the new branch",
|
|
})
|
|
.option("base", {
|
|
alias: "b",
|
|
describe: "base branch",
|
|
})
|
|
.option("upstream", {
|
|
alias: "u",
|
|
default: currentBranch,
|
|
describe:
|
|
"branch that is dependent on the new branch",
|
|
})
|
|
.demandOption(["branch"]);
|
|
},
|
|
newCommand
|
|
)
|
|
.fail((msg, err, yargs) => {
|
|
try {
|
|
const message = msg || err.message;
|
|
console.error(message);
|
|
process.exit(1);
|
|
} catch (e) {
|
|
yargs.showHelp();
|
|
}
|
|
})
|
|
.help()
|
|
.demandCommand(1, "")
|
|
.strict().argv;
|
|
}
|