Skip to content

Commit

Permalink
feat: add initial command tool options
Browse files Browse the repository at this point in the history
  • Loading branch information
MHCYR authored and adantoscano committed Oct 5, 2023
1 parent 7ccf8dc commit b6623b7
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import OpenApiMocker from 'open-api-mocker';
import cloneGitRepository from './services/clone-git-repository.js';
import findOasFromDir from './services/find-oas-from-dir.js';
const { program } = require("commander");

const main = async () => {
const testRepoSSH = "[email protected]:os3/manatee/sirenia.git"; // TODO: replace by user input
const testRepoHTTPS = "https://gitlab.sngular.com/os3/manatee/sirenia.git"; // TODO: replace by user input
await cloneGitRepository(testRepoSSH);
program
.requiredOption("-r,--repository-url <value>", "The URL of the repo or path")
.option(
"-s,--schemas-directory <value>",
"Path/name of the schemas directory"
)
.option("-p, --port [number]", "Port to run the server on", 3000)
.option(
"-d,--delete-repo-directory",
"Delete the repo directory after cloning"
)
.option("-a, --add-gitignore", "Add schemas repository to .gitignore");

const schemas = await findOasFromDir('./tests');

console.log('Schemas found:');
schemas.forEach(el => console.log(`-- ${el.filePath}`));

const openApiMocker = new OpenApiMocker({
port: 5000,
schema: schemas[0].filePath,
watch: true,
});

await openApiMocker.validate();

await openApiMocker.mock();
const main = () => {
program.parse(process.argv);
const options = program.opts();
console.table(options);
};

main();

0 comments on commit b6623b7

Please sign in to comment.