Enable cli description to have free args title
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import {defaultCliArgsParser} from "./src/CliArgsParser";
|
import {CliArgsParser, getDefaultCliDescription} from "./src/CliArgsParser";
|
||||||
import {getAdapter} from "./src/Adapter";
|
import {getAdapter} from "./src/Adapter";
|
||||||
import {directRunner} from "./src/KotlinTestRunner";
|
import {directRunner} from "./src/KotlinTestRunner";
|
||||||
|
|
||||||
const kotlin_test = require('kotlin-test');
|
const kotlin_test = require('kotlin-test');
|
||||||
|
|
||||||
const parser = defaultCliArgsParser;
|
const parser = new CliArgsParser(getDefaultCliDescription());
|
||||||
|
|
||||||
const processArgs = process.argv.slice(2);
|
const processArgs = process.argv.slice(2);
|
||||||
const untypedArgs = parser.parse(processArgs);
|
const untypedArgs = parser.parse(processArgs);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export type CliDescription = {
|
|||||||
args: {
|
args: {
|
||||||
[k: string]: CliArgDescription,
|
[k: string]: CliArgDescription,
|
||||||
},
|
},
|
||||||
freeArgsTitle: string
|
freeArgsTitle: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CliArgValues = {
|
export type CliArgValues = {
|
||||||
@@ -107,7 +107,7 @@ export class CliArgsParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.free.length == 0) {
|
if (description.freeArgsTitle && result.free.length == 0) {
|
||||||
this.badArgsExit(`At least one ${description.freeArgsTitle} should be provided`)
|
this.badArgsExit(`At least one ${description.freeArgsTitle} should be provided`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,8 @@ export class CliArgsParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultCliDescription: CliDescription = {
|
export function getDefaultCliDescription(): CliDescription {
|
||||||
|
return {
|
||||||
version: VERSION,
|
version: VERSION,
|
||||||
bin: BIN,
|
bin: BIN,
|
||||||
description: DESCRIPTION,
|
description: DESCRIPTION,
|
||||||
@@ -149,6 +150,5 @@ export const defaultCliDescription: CliDescription = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
freeArgsTitle: "module_name"
|
freeArgsTitle: "module_name"
|
||||||
};
|
};
|
||||||
|
}
|
||||||
export const defaultCliArgsParser: CliArgsParser = new CliArgsParser(defaultCliDescription);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user