77from collections import defaultdict
88from pprint import pprint
99
10- from .. import StyleFrame , Container , Styler , version
10+ from .. import StyleFrame , Container , Styler , version , tests
1111from .tests .json_schema import commandline_json_schema
1212
1313styler_kwargs = set (inspect .signature (Styler ).parameters .keys ())
@@ -91,17 +91,18 @@ def get_cli_args():
9191
9292 group .add_argument ('-v' , '--version' , action = 'store_true' , default = False ,
9393 help = 'print versions of the Python interpreter, openpyxl, pandas and StyleFrame then quit' )
94- group .add_argument ('--json_path' , help = 'path to json file which defines the Excel file' )
94+ group .add_argument ('--json_path' , '--json-path' , help = 'path to json file which defines the Excel file' )
9595 group .add_argument ('--json' , help = 'json string which defines the Excel file' )
9696 group .add_argument ('--show-schema' , action = 'store_true' , help = 'Print the JSON schema used for validation and exit' ,
9797 default = False )
98- parser .add_argument ('--output_path' , help = 'path of output Excel file, defaults to output.xlsx' ,
98+ group .add_argument ('--test' , help = 'execute tests' , action = 'store_true' )
99+ parser .add_argument ('--output_path' , '--output-path' , help = 'path of output Excel file, defaults to output.xlsx' ,
99100 default = 'output.xlsx' )
100101
101102 cli_args = parser .parse_args ()
102103
103- if not any ((cli_args .version , cli_args .show_schema )) and not any ((cli_args .json_path , cli_args .json )):
104- parser .error ('Either --json_path or --json are required when not using -v. ' )
104+ if not any ((cli_args .version , cli_args .show_schema , cli_args . test )) and not any ((cli_args .json_path , cli_args .json )):
105+ parser .error ('Either --json_path or --json are required when not using -v or --show-schema ' )
105106
106107 return cli_args
107108
@@ -114,6 +115,9 @@ def execute_from_command_line():
114115 if cli_args .show_schema :
115116 pprint (commandline_json_schema )
116117 return
118+ if cli_args .test :
119+ tests .tests .run ()
120+ return
117121 CommandLineInterface (input_path = cli_args .json_path , input_json = cli_args .json ,
118122 output_path = cli_args .output_path ).parse_as_json ()
119123
0 commit comments