mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-03 12:02:53 +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
|
||||
*
|
||||
* 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
|
||||
.version(connectorVersion)
|
||||
.command('run')
|
||||
.option('-b <backend>', 'URL of the StApps backend deployment', 'http://localhost:3000')
|
||||
.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')
|
||||
.action(async (backend: string, origin: string, licensePlate: string) => {
|
||||
if (backend.length === 0) {
|
||||
.command('run <backendURL> <origin> <licensePlate>')
|
||||
.action(async (backendURL: string, origin: string, licensePlate: string) => {
|
||||
|
||||
if (backendURL.length === 0) {
|
||||
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)) {
|
||||
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
|
||||
const connector = new MinimalConnector(licensePlate, origin);
|
||||
|
||||
await executeConnector(backend, connector);
|
||||
await executeConnector(backendURL, connector);
|
||||
Logger.ok('Done');
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user