Skip to content

Commit 1b0ee0e

Browse files
committed
use click features to check if argument is a file
1 parent cf0c435 commit 1b0ee0e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

scripts/lambda

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ def cli():
1616

1717

1818
@click.command(help="Create a new function for Lambda.")
19-
@click.argument('folder', default=False)
19+
@click.argument('folder', nargs=-1, type=click.Path(file_okay=False, writable=True))
2020
def init(folder):
2121
path = CURRENT_DIR
22-
if folder:
23-
path = "{}/{}".format(CURRENT_DIR, folder)
24-
if os.path.isfile(path):
25-
raise click.ClickException("{} is a file".format(path))
22+
if len(folder) > 0:
23+
path = "{}/{}".format(CURRENT_DIR, folder[0])
2624
if not os.path.exists(path):
2725
os.makedirs(path)
2826
aws_lambda.init(path)

0 commit comments

Comments
 (0)