From 0c83dce817d219ade73fb89fd1be0ba28c3aa655 Mon Sep 17 00:00:00 2001 From: freddyaboulton Date: Thu, 21 Sep 2023 16:42:01 -0400 Subject: [PATCH 1/2] Add overwrite flag to create command --- gradio/cli/commands/create.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gradio/cli/commands/create.py b/gradio/cli/commands/create.py index 8555da1fc5f2..3477ea58b72f 100644 --- a/gradio/cli/commands/create.py +++ b/gradio/cli/commands/create.py @@ -195,13 +195,22 @@ def _create( str, typer.Option(help="NPM install command to use. Default is 'npm install'."), ] = "npm install", + overwrite: Annotated[ + bool, + typer.Option(help="Whether to overwrite the existing component if it exists.") + ] = False ): if not directory: directory = pathlib.Path(name.lower()) if not package_name: package_name = f"gradio_{name.lower()}" - directory.mkdir(exist_ok=True) + if directory.exists() and not overwrite: + raise ValueError(f"The directory {directory.resolve()} already exists. " + "Please set --overwrite flag or pass in the name " + "of a directory that does not already exist via the --directory option.") + + directory.mkdir(exist_ok=overwrite) if in_test_dir(): npm_install = "pnpm i --ignore-scripts" From 6865747c0f3d468a875499ffeab545fffc9b1dc3 Mon Sep 17 00:00:00 2001 From: gradio-pr-bot Date: Thu, 21 Sep 2023 20:43:50 +0000 Subject: [PATCH 2/2] add changeset --- .changeset/slick-pants-stand.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slick-pants-stand.md diff --git a/.changeset/slick-pants-stand.md b/.changeset/slick-pants-stand.md new file mode 100644 index 000000000000..b9b2298a8d7c --- /dev/null +++ b/.changeset/slick-pants-stand.md @@ -0,0 +1,5 @@ +--- +"gradio": minor +--- + +feat:Add overwrite flag to create command