Skip to content

Commit f878081

Browse files
committed
Add proper terminal wrappin, and strict options usage
1 parent 86d3dde commit f878081

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {CommandModule} from "yargs";
33
import {Parser} from "./parser";
44
import * as defaultCmd from "./default_cmd";
55
import * as state from "./state";
6+
import * as fs from "fs-extra";
67

78
process.on('uncaughtException', (err) => {
89
process.stderr.write(`${err.stack ? err.stack : err}\n`);
@@ -29,20 +30,24 @@ Array.prototype.first = function() {
2930
};
3031

3132
const argv = yargs
32-
.version("4.6.1")
33+
.version("4.7.0")
3334
.showHelpOnFail(false)
34-
.wrap(180)
35+
.wrap(yargs.terminalWidth())
3536
.command(defaultCmd as CommandModule)
3637
.usage("Find more information at https://github.com/firecow/gitlab-ci-local")
38+
.strictOptions()
3739
.option("manual", {type: "array", description: "One or more manual jobs to run during a pipeline", requiresArg: true})
3840
.option("list", {type: "string", description: "List jobs and job information", requiresArg: false})
3941
.option("cwd", {type: "string", description: "Path to a gitlab-ci.yml", requiresArg: true})
4042
.option("completion", {type: "string", description: "Generate bash completion script", requiresArg: false})
4143
.option("needs", {type: "boolean", description: "Run needed jobs, when executing a single job", requiresArg: false})
42-
.completion("completion", false, async (current, a) => {
43-
const cwd = a.cwd as string || process.cwd();
44+
.completion("completion", false, async (current, yargsArgv) => {
45+
const cwd = yargsArgv.cwd as string || process.cwd();
4446
const pipelineIid = await state.getPipelineIid(cwd);
4547
const parser = await Parser.create(cwd, pipelineIid, true);
48+
// await fs.appendFile(".gitlab-ci-bash-complete.log", JSON.stringify(current) + "\n");
49+
// await fs.appendFile(".gitlab-ci-bash-complete.log", JSON.stringify(yargsArgv) + "\n");
50+
// await fs.appendFile(".gitlab-ci-bash-complete.log", "\n");
4651
return parser.getJobNames();
4752
})
4853
.argv;

0 commit comments

Comments
 (0)