diff --git a/src/cli.ts b/src/cli.ts index cebb402..cb1c514 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -26,10 +26,13 @@ cli.command("whoami", "Display current user").action(async options => { await commands.whoami(cli, options); }); -cli.command("init", "Init a dico in your project").action(async options => { - await middlewares.signedInOnly(); - await commands.init(cli, options); -}); +cli + .command("init", "Init a dico in your project") + .option("-f, --force", "Override existing `dico.config.json`") + .action(async options => { + await middlewares.signedInOnly(); + await commands.init(cli, options); + }); cli.version(VERSION); cli.help(commands.help); diff --git a/src/commands/init.ts b/src/commands/init.ts index 0da1637..8fdef61 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -113,9 +113,9 @@ const initConfig = { export const init = async ( _: CAC, - __: { [key: string]: never } + options: { [key: string]: never } ): Promise => { - if (dicojson.exists()) { + if (!options.force && dicojson.exists()) { logger.error(messages.DicoJSONAlreadyExists, dicojson.getPath()); exit(1); }