eclipse-thingweb / playground

Browser application for validating and designing W3C Thing Descriptions and Thing Models.
https://playground.thingweb.io/
Other
29 stars 19 forks source link

Take multiple inputs from CLI #397

Closed edbingo closed 1 year ago

edbingo commented 1 year ago

It would be useful if you could pass multiple files / folders with the input flag. This seems like an easy fix using a for/of loop.

egekorkan commented 1 year ago

This is actually already possible with the -i parameter. Please see https://github.com/thingweb/thingweb-playground/tree/master/packages/cli#parameters

edbingo commented 1 year ago

This doesn't seem to be working for me:

> node packages/cli/index.js -i packages/core/examples/tms/valid/affordances.json packages/core/examples/tms/valid/security.json
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received an instance of Array
egekorkan commented 1 year ago

Sorry, I have misunderstood your comment. Currently, you can either specify a single file or a single folder. You want to pass multiple file names right?

edbingo commented 1 year ago

Exactly. This could be done pretty unintrusively with a for/of loop:

let inputArray = myArguments.input

if (myArguments.type === 'TD') {
    for (input of inputArray) {
        if (myArguments.assertions === true) {
            tdAssertionReport(input)
        }
        else if (myArguments.openApi === true) {
            openApiGeneration(input)
        }
        else if (myArguments.asyncApi === true) {
            asyncApiGeneration(input)
        }
        else if (myArguments.defaultAdd === true || myArguments.defaultRem === true) {
            defaultManipulation(input)
        }
        else {
            coreValidation(input)
        }
    }
}

See here

egekorkan commented 1 year ago

This looks good to me, can you add a corresponding test as well?