Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from pathlib import Path 

2import typer 

3 

4from cookiecutter.main import cookiecutter as cookiecutter_main 

5 

6app = typer.Typer() 

7 

8 

9@app.command() 

10def cookiecutter( 

11 template: str = typer.Option( 

12 "", 

13 help="The Cookiecutter template to use. " 

14 "If left blank then it uses the default template in this version of torchapp. " 

15 "If 'gh' or 'github' then it uses the latest torchapp cookiecutter template at https://github.com/rbturnbull/torchapp-cookiecutter", 

16 ), 

17 checkout: str = typer.Option( 

18 None, help="A branch, tag or commit to checkout after git clone" 

19 ), 

20 no_input: bool = typer.Option( 

21 False, help="Do not prompt for parameters and only use cookiecutter.json file content" 

22 ), 

23 extra_context: str = typer.Option(None, help=""), 

24 replay: bool = typer.Option( 

25 False, help="Do not prompt for parameters and only use information entered previously" 

26 ), 

27 overwrite_if_exists: bool = typer.Option( 

28 False, help="Overwrite the contents of the output directory if it already exists" 

29 ), 

30 output_dir: Path = typer.Option( 

31 ".", help="Where to output the generated project dir into" 

32 ), 

33 config_file: Path = typer.Option(None, help="User configuration file"), 

34 default_config: bool = typer.Option( 

35 False, help="Do not load a config file. Use the defaults instead" 

36 ), 

37 directory: str = typer.Option( 

38 None, 

39 help="Directory within repo that holds cookiecutter.json file for advanced repositories with multi templates in it", 

40 ), 

41 skip_if_file_exists: bool = typer.Option( 

42 False, help="Skip the files in the corresponding directories if they already exist" 

43 ), 

44): 

45 """ 

46 Generate a torchapp project using Cookiecutter (https://github.com/audreyr/cookiecutter) 

47 """ 

48 if not template: 

49 template = Path(__file__).parent.resolve() / "cookiecutter" 

50 elif template in ["gh", "github"]: 

51 template = "https://github.com/rbturnbull/torchapp-cookiecutter" 

52 

53 return cookiecutter_main( 

54 template=str(template), 

55 checkout=checkout, 

56 no_input=no_input, 

57 extra_context=extra_context, 

58 replay=replay, 

59 overwrite_if_exists=overwrite_if_exists, 

60 output_dir=output_dir, 

61 config_file=config_file, 

62 default_config=default_config, 

63 directory=directory, 

64 skip_if_file_exists=skip_if_file_exists, 

65 )