@@ -38,6 +38,7 @@ def main():
3838 "\n This tool allows to encode/decode input strings/files with an extended set of codecs.\n \n " \
3939 .format (__version__ , __author__ , __email__ , __copyright__ , __license__ , __source__ )
4040 examples = "usage examples:\n - " + "\n - " .join ([
41+ "codext --search bitcoin" ,
4142 "codext -d base32 -i file.b32" ,
4243 "codext morse < to_be_encoded.txt" ,
4344 "echo \" test\" | codext base100" ,
@@ -56,7 +57,15 @@ def main():
5657 parser .add_argument ("-i" , "--input-file" , dest = "infile" , help = "input file (if none, take stdin as input)" )
5758 parser .add_argument ("-o" , "--output-file" , dest = "outfile" , help = "output file (if none, display result to stdout)" )
5859 parser .add_argument ("-s" , "--strip-newlines" , action = "store_true" , dest = "strip" , help = "strip newlines from input" )
60+ parser .add_argument ("--search" , action = "store_true" , help = "search for encoding names" )
5961 args = parser .parse_args ()
62+ # if a search pattern is given, only handle it
63+ if args .search :
64+ results = []
65+ for enc in args .encoding :
66+ results .extend (codecs .search (enc ))
67+ print (", " .join (results ) or "No encoding found" )
68+ return
6069 # handle input file or stdin
6170 if args .infile :
6271 with open (args .infile , 'rb' ) as f :
0 commit comments