<s> import os <EOL> import sys <EOL> from argparse import ArgumentParser , REMAINDER <EOL> from tiget import __version__ <EOL> from tiget . git import is_repo_initialized <EOL> from tiget . repl import Repl <EOL> from tiget . conf import settings <EOL> from tiget . utils import print_error , load_file , post_mortem <EOL> from tiget . cmds import CmdError , cmd_execfile , cmd_execv <EOL> from tiget . plugins import load_plugin <EOL> def load_config ( ) : <EOL> files = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> repo = settings . core . repository <EOL> if repo and repo . workdir : <EOL> files . append ( os . path . join ( repo . workdir , '<STR_LIT>' ) ) <EOL> for filename in files : <EOL> try : <EOL> f = load_file ( filename ) <EOL> except IOError : <EOL> continue <EOL> cmd_execfile ( f ) <EOL> def main ( ) : <EOL> parser = ArgumentParser ( description = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , default = sys . stdin . isatty ( ) , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> default = True , help = '<STR_LIT>' ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , dest = '<STR_LIT>' , <EOL> default = False , help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , nargs = REMAINDER , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> if args . print_version : <EOL> print ( '<STR_LIT>' . format ( __version__ ) ) <EOL> return <EOL> load_plugin ( '<STR_LIT>' ) <EOL> if not is_repo_initialized ( ) : <EOL> print_error ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> try : <EOL> if args . load_config : <EOL> load_config ( ) <EOL> if args . cmd : <EOL> cmd_execv ( args . cmd ) <EOL> elif args . interactive : <EOL> Repl ( ) . run ( ) <EOL> else : <EOL> cmd_execfile ( sys . stdin ) <EOL> except CmdError as e : <EOL> print_error ( e ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> except Exception as e : <EOL> post_mortem ( ) <EOL> sys . exit ( <NUM_LIT:1> ) </s>
