<s> import click <EOL> import logbook <EOL> from logbook . more import ColorizedStderrHandler <EOL> from logbook . handlers import NullHandler <EOL> import os <EOL> from . exc import UnleashError <EOL> from . plugin import PluginGraph <EOL> from . boilerplate import Recipe <EOL> from . unleash import Unleash <EOL> from . import _context , opts <EOL> log = logbook . Logger ( '<STR_LIT>' ) <EOL> def umask_value ( s ) : <EOL> if s == '<STR_LIT>' : <EOL> return False <EOL> val = int ( s , <NUM_LIT:8> ) <EOL> if val > <NUM_LIT> or val < <NUM_LIT:0> : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> return val <EOL> @ click . group ( ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = False , is_flag = True , <EOL> help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , flag_value = logbook . DEBUG ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , flag_value = logbook . WARNING ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = '<STR_LIT:.>' , <EOL> type = click . Path ( exists = True , file_okay = False , dir_okay = True , <EOL> resolve_path = True ) , <EOL> help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , is_flag = True ) <EOL> @ click . option ( '<STR_LIT>' , default = '<STR_LIT>' , type = umask_value ) <EOL> @ click . version_option ( ) <EOL> @ click . pass_context <EOL> def cli ( ctx , root , loglevel , batch , umask , ** kwargs ) : <EOL> unleash = ctx . obj <EOL> if loglevel is None : <EOL> loglevel = logbook . INFO <EOL> NullHandler ( ) . push_application ( ) <EOL> ColorizedStderrHandler ( format_string = '<STR_LIT>' , <EOL> level = loglevel ) . push_application ( ) <EOL> if not umask is False : <EOL> log . debug ( '<STR_LIT>' . format ( umask ) ) <EOL> prev_umask = os . umask ( umask ) <EOL> if prev_umask != umask : <EOL> log . info ( '<STR_LIT>' . format ( <EOL> prev_umask , umask ) <EOL> ) <EOL> _context . push ( { <EOL> '<STR_LIT>' : { } <EOL> } ) <EOL> opts [ '<STR_LIT>' ] = not batch , <EOL> opts [ '<STR_LIT:root>' ] = root <EOL> opts . update ( kwargs ) <EOL> if ctx . invoked_subcommand != '<STR_LIT>' : <EOL> unleash . _init_repo ( ) <EOL> log . debug ( '<STR_LIT>' . format ( unleash . plugins . resolve_order ( ) ) ) <EOL> @ cli . command ( ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , is_flag = True , default = False , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , default = True , <EOL> help = '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> @ click . pass_obj <EOL> def release ( unleash , ref , ** kwargs ) : <EOL> opts . update ( kwargs ) <EOL> unleash . create_release ( ref ) <EOL> @ cli . command ( ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = None , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ click . pass_obj <EOL> def publish ( unleash , ref , ** kwargs ) : <EOL> opts . update ( kwargs ) <EOL> unleash . publish ( ref ) <EOL> @ cli . command ( ) <EOL> @ click . argument ( '<STR_LIT>' ) <EOL> @ click . option ( '<STR_LIT>' , '<STR_LIT>' , default = '<STR_LIT:.>' , type = click . Path ( ) ) <EOL> def boilerplate ( recipe , destination ) : <EOL> rcp = Recipe ( recipe ) <EOL> rcp . collect_answers ( ) <EOL> rcp . run ( destination ) <EOL> def main ( ) : <EOL> try : <EOL> with NullHandler ( ) . applicationbound ( ) : <EOL> plugins = PluginGraph ( ) <EOL> plugins . collect_plugins ( ) <EOL> plugins . notify ( '<STR_LIT>' , cli ) <EOL> unleash = Unleash ( plugins ) <EOL> cli ( obj = unleash ) <EOL> except UnleashError as e : <EOL> log . critical ( e ) </s>
