<s> '''<STR_LIT>''' <EOL> from sys import argv , stdout , exit <EOL> from rsstail . main import parseopt <EOL> usage = '<STR_LIT>' <EOL> if len ( argv ) == <NUM_LIT:1> or argv [ <NUM_LIT:1> ] not in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> stdout . write ( usage ) ; exit ( <NUM_LIT:1> ) <EOL> parser = parseopt ( ) [ <NUM_LIT:0> ] <EOL> options = sum ( [ i . option_list for i in parser . option_groups ] , [ ] ) <EOL> zsh_tmpl = '''<STR_LIT>''' <EOL> bash_tmpl = '''<STR_LIT>''' <EOL> escapable = lambda c : c == '<STR_LIT:[>' or c == '<STR_LIT:]>' or c == '<STR_LIT:">' <EOL> def escape ( s ) : <EOL> res = [ ( '<STR_LIT>' % c ) if escapable ( c ) else c for c in s ] <EOL> return '<STR_LIT>' . join ( res ) <EOL> def zshopts ( ) : <EOL> fmt = '<STR_LIT>' <EOL> def getmetavar ( action ) : <EOL> if action . takes_value ( ) : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return '<STR_LIT>' <EOL> long_opts = [ ( a . _long_opts , getmetavar ( a ) , a . help ) for a in options ] <EOL> short_opts = [ ( a . _short_opts , getmetavar ( a ) , a . help ) for a in options ] <EOL> for op in ( long_opts , short_opts ) : <EOL> for o , m , h in op : <EOL> yield fmt % ( o [ <NUM_LIT:0> ] , escape ( h ) , m , '<STR_LIT>' ) <EOL> def bashopts ( ) : <EOL> opts = [ a . _long_opts for a in options ] <EOL> opts += [ a . _short_opts for a in options ] <EOL> opts = sum ( opts , [ ] ) <EOL> return '<STR_LIT:U+0020>' . join ( opts ) <EOL> if argv [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> opts = [ '<STR_LIT>' % i for i in zshopts ( ) ] <EOL> stdout . write ( zsh_tmpl % '<STR_LIT:\n>' . join ( opts ) ) <EOL> elif argv [ <NUM_LIT:1> ] == '<STR_LIT>' : <EOL> stdout . write ( bash_tmpl % bashopts ( ) ) </s>
