mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-06 21:42:49 +00:00
fix: use arguments instead of options
This commit is contained in:
18
src/cli.ts
18
src/cli.ts
@@ -30,18 +30,20 @@ process.on('unhandledRejection', (error) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses arguments to paramtrize the connector execution
|
* Uses arguments to paramtrize the connector execution
|
||||||
|
*
|
||||||
|
* backendURL - URL of the StApps backend deployment e.g. http://localhost:3000
|
||||||
|
* origin - Origin, where the data comes from. Typically the name of the connector e.g. minimal-connector
|
||||||
|
* licensePlate - The license plate of your school. Must be matched to a SCNamespace e.g. f-u
|
||||||
*/
|
*/
|
||||||
commander
|
commander
|
||||||
.version(connectorVersion)
|
.version(connectorVersion)
|
||||||
.command('run')
|
.command('run <backendURL> <origin> <licensePlate>')
|
||||||
.option('-b <backend>', 'URL of the StApps backend deployment', 'http://localhost:3000')
|
.action(async (backendURL: string, origin: string, licensePlate: string) => {
|
||||||
.option('-o <origin>', 'Origin, where the data comes from. Typically the name of the connector', 'minimal-connector')
|
|
||||||
.option('-l <licensePlate>', 'The license plate of your school. Must be matched to a SCNamespace', 'f-u')
|
if (backendURL.length === 0) {
|
||||||
.action(async (backend: string, origin: string, licensePlate: string) => {
|
|
||||||
if (backend.length === 0) {
|
|
||||||
throw new Error('Param "backend" needs to have a length greater zero.');
|
throw new Error('Param "backend" needs to have a length greater zero.');
|
||||||
}
|
}
|
||||||
const originRegex = /^[a-z\-\_0-9]*$/;
|
const originRegex = /^[a-z\-\_0-9]+$/;
|
||||||
if (!originRegex.test(origin)) {
|
if (!originRegex.test(origin)) {
|
||||||
throw new Error('Origin name can only consist of lowercase letters from a-z, "-", "_" and integer numbers.');
|
throw new Error('Origin name can only consist of lowercase letters from a-z, "-", "_" and integer numbers.');
|
||||||
}
|
}
|
||||||
@@ -53,7 +55,7 @@ commander
|
|||||||
// TODO for connector-developers: set your connector here
|
// TODO for connector-developers: set your connector here
|
||||||
const connector = new MinimalConnector(licensePlate, origin);
|
const connector = new MinimalConnector(licensePlate, origin);
|
||||||
|
|
||||||
await executeConnector(backend, connector);
|
await executeConnector(backendURL, connector);
|
||||||
Logger.ok('Done');
|
Logger.ok('Done');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user