mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
28 lines
839 B
TypeScript
28 lines
839 B
TypeScript
import { Argument, Command } from "commander";
|
|
|
|
import { createProviders } from "./create-providers";
|
|
import { addProviderPrompt } from "./prompt";
|
|
import { availableProviders, type ProviderId } from "./providers";
|
|
|
|
export const createProviderAction = async (
|
|
providers: ProviderId[],
|
|
options: { path?: string },
|
|
) => {
|
|
if (!providers.length) {
|
|
const { providers, providersPath } = await addProviderPrompt();
|
|
|
|
return createProviders(providers, providersPath);
|
|
}
|
|
|
|
createProviders(providers, options.path);
|
|
};
|
|
|
|
export const ProviderCommand = new Command("provider")
|
|
.addArgument(
|
|
new Argument("[providers...]", "Create provider(s)")
|
|
.choices(availableProviders.map((provider) => provider.id))
|
|
.default([]),
|
|
)
|
|
.option("-p, --path [path]", "Path to generate providers")
|
|
.action(createProviderAction);
|