1616
1717
1818@click .command ()
19+ {% - if cookiecutter .file_input == "Yes" % }
1920@click .option (
20- "--input-file" , help = "Input file" , type = click .File ("rt" ), default = sys .stdin
21+ "--input-file" , help = "Input file [default: STDIN] " , type = click .File ("rt" ), default = sys .stdin
2122)
23+ {% - endif % }
24+ {% - if cookiecutter .file_output == "Yes" % }
2225@click .option (
23- "--output-file" , help = "Output file" , type = click .File ("at" ), default = sys .stdout
26+ "--output-file" , help = "Output file [default: STDOUT] " , type = click .File ("at" ), default = sys .stdout
2427)
28+ {% - endif % }
2529@click .option (
2630 "--log-level" ,
2731 default = "WARNING" ,
2832 type = click .Choice (["DEBUG" , "INFO" , "WARNING" , "ERROR" , "CRITICAL" ]),
2933 show_default = True ,
3034 help = "Set logging level." ,
3135)
32- def main (input_file , output_file , log_level ):
36+ def main (
37+ {% - if cookiecutter .file_input == "Yes" % }
38+ input_file ,
39+ {% - endif % }
40+ {% - if cookiecutter .file_output == "Yes" % }
41+ output_file ,
42+ {% - endif % }
43+ log_level ):
3344 """Console script for {{cookiecutter.project_slug}}."""
3445 log_levels = {
3546 "DEBUG" : logging .DEBUG ,
@@ -39,11 +50,13 @@ def main(input_file, output_file, log_level):
3950 "CRITICAL" : logging .CRITICAL ,
4051 }
4152 logging .getLogger ().setLevel (log_levels [log_level ])
53+ {% - if cookiecutter .file_input == "Yes" % }
4254 if input_file .isatty ():
4355 logging .critical ("Input from stdin which is a tty - aborting" )
4456 return 128
4557 with input_file :
4658 data = input_file .read ()
59+ {% - endif % }
4760 return 0
4861
4962
0 commit comments