def help_option(*param_decls, **attrs):
 def decorator(f):
  def callback(ctx, param, value):
   if (value and (not ctx.resilient_parsing)):
    echo(ctx.get_help(), color=ctx.color)
    ctx.exit()
  attrs.setdefault('is_flag', True)
  attrs.setdefault('expose_value', False)
  attrs.setdefault('help', 'Show this message and exit.')
  attrs.setdefault('is_eager', True)
  attrs['callback'] = callback
  return option(*(param_decls or ('--help',)), **attrs)(f)
 return decorator

def help_option ( * param_decls , ** attrs ) : def decorator ( f ) : def callback ( ctx , param , value ) : if ( value and ( not ctx . resilient_parsing ) ) : echo ( ctx . get_help ( ) , color = ctx . color ) ctx . exit ( ) attrs . setdefault ( 'is_flag' , True ) attrs . setdefault ( 'expose_value' , False ) attrs . setdefault ( 'help' , 'Show this message and exit.' ) attrs . setdefault ( 'is_eager' , True ) attrs [ 'callback' ] = callback return option ( * ( param_decls or ( '--help' , ) ) , ** attrs ) ( f ) return decorator
adds a --help option which immediately ends the program printing out the help page .