66from code_counter import __version__
77
88
9- def config_args_type (args ):
9+ def split_args (args ):
1010 return list (args .split (',' ))
1111
1212
@@ -26,24 +26,25 @@ def __init__(self):
2626 if not hasattr (self , args .command ):
2727 print ("Unrecognized command" )
2828 parser .print_help ()
29+ exit (1 )
2930 self .args = {args .command : getattr (self , args .command )()}
3031
3132 def search (self ):
3233 parser = argparse .ArgumentParser (
3334 description = "Search code in the given path(s)" )
34- parser .add_argument ('path' ,
35+ parser .add_argument ('input_path' , type = split_args ,
3536 help = "specify a file or directory path you want to count or use CONFIG placeholder to configure" )
3637 parser .add_argument ('-v' , '--verbose' , dest = "verbose" , action = 'store_true' ,
3738 help = "show verbose infomation" )
3839 parser .add_argument ('-g' , '--graph' , dest = 'graph' , action = 'store_true' ,
3940 help = "choose to whether to visualize the result" )
4041 parser .add_argument ('-o' , '--output' , dest = 'output_path' ,
4142 help = "specify a output path if you want to store the result" )
42- parser .add_argument ('--suffix' , dest = 'suffix' , type = config_args_type ,
43+ parser .add_argument ('--suffix' , dest = 'suffix' , type = split_args ,
4344 help = "what code files do you want to count, this parameter is disposable" )
44- parser .add_argument ('--comment' , dest = 'comment' , type = config_args_type ,
45+ parser .add_argument ('--comment' , dest = 'comment' , type = split_args ,
4546 help = "the comment symbol, which can be judged whether the current line is a comment, this parameter is disposable" )
46- parser .add_argument ('--ignore' , dest = 'ignore' , type = config_args_type ,
47+ parser .add_argument ('--ignore' , dest = 'ignore' , type = split_args ,
4748 help = "ignore some directories or files that you don't want to count, this parameter is disposable" )
4849 return parser .parse_args (sys .argv [2 :])
4950
@@ -52,19 +53,19 @@ def config(self):
5253 description = "A command-line interface (CLI) utility that can help you easily count code and display detailed results." )
5354 parser .add_argument ('--list' , dest = 'show_list' , action = 'store_true' ,
5455 help = "list all variables set in config file, along with their values" )
55- parser .add_argument ('--suffix-reset' , dest = 'suffix_reset' , type = config_args_type ,
56+ parser .add_argument ('--suffix-reset' , dest = 'suffix_reset' , type = split_args ,
5657 help = "override 'suffix' in config and count codes according to this value" )
57- parser .add_argument ('--suffix-add' , dest = 'suffix_add' , type = config_args_type ,
58+ parser .add_argument ('--suffix-add' , dest = 'suffix_add' , type = split_args ,
5859 help = "append new value for 'suffix' in config and count codes according to this value" )
5960
60- parser .add_argument ('--comment-reset' , dest = 'comment_reset' , type = config_args_type ,
61+ parser .add_argument ('--comment-reset' , dest = 'comment_reset' , type = split_args ,
6162 help = "override 'comment' in config and count comment lines according to this value" )
62- parser .add_argument ('--comment-add' , dest = 'comment_add' , type = config_args_type ,
63+ parser .add_argument ('--comment-add' , dest = 'comment_add' , type = split_args ,
6364 help = "append new value for 'comment' in config and count comment lines according to this value" )
6465
65- parser .add_argument ('--ignore-reset' , dest = 'ignore_reset' , type = config_args_type ,
66+ parser .add_argument ('--ignore-reset' , dest = 'ignore_reset' , type = split_args ,
6667 help = "override 'ignore' in config and ignore some files or directory according to this value" )
67- parser .add_argument ('--ignore-add' , dest = 'ignore_add' , type = config_args_type ,
68+ parser .add_argument ('--ignore-add' , dest = 'ignore_add' , type = split_args ,
6869 help = "append new value for 'ignore' in config and ignore some files or directory according to this value" )
6970
7071 parser .add_argument ('--restore' , dest = 'restore' , action = 'store_true' ,
0 commit comments