()
| 68 | print(' {:<19} {}'.format(choice.dest, choice.help)) |
| 69 | |
| 70 | def main(): |
| 71 | parser = argparse.ArgumentParser( |
| 72 | description=( |
| 73 | 'Gitless: a version control system built on top of Git.\nMore info, ' |
| 74 | 'downloads and documentation at {0}'.format(URL)), |
| 75 | formatter_class=argparse.RawDescriptionHelpFormatter) |
| 76 | parser.add_argument( |
| 77 | '--version', action='version', version=( |
| 78 | 'GL Version: {0}\nYou can check if there\'s a new version of Gitless ' |
| 79 | 'available at {1}'.format(__version__, URL))) |
| 80 | subparsers = parser.add_subparsers(title='subcommands', dest='subcmd_name') |
| 81 | subparsers.required = True |
| 82 | |
| 83 | sub_cmds = [ |
| 84 | gl_track, gl_untrack, gl_status, gl_diff, gl_commit, gl_branch, gl_tag, |
| 85 | gl_checkout, gl_merge, gl_resolve, gl_fuse, gl_remote, gl_publish, |
| 86 | gl_switch, gl_init, gl_history] |
| 87 | for sub_cmd in sub_cmds: |
| 88 | sub_cmd.parser(subparsers, repo) |
| 89 | |
| 90 | if len(sys.argv) == 1: |
| 91 | print_help(parser) |
| 92 | return SUCCESS |
| 93 | |
| 94 | args = parser.parse_args() |
| 95 | try: |
| 96 | if args.subcmd_name != 'init' and not repo: |
| 97 | raise core.NotInRepoError('You are not in a Gitless\'s repository') |
| 98 | |
| 99 | return SUCCESS if args.func(args, repo) else ERRORS_FOUND |
| 100 | except KeyboardInterrupt: |
| 101 | pprint.puts('\n') |
| 102 | pprint.msg('Keyboard interrupt detected, operation aborted') |
| 103 | return SUCCESS |
| 104 | except core.NotInRepoError as e: |
| 105 | pprint.err(e) |
| 106 | pprint.err_exp('do gl init to turn this directory into an empty repository') |
| 107 | pprint.err_exp('do gl init remote_repo to clone an existing repository') |
| 108 | return NOT_IN_GL_REPO |
| 109 | except (ValueError, pygit2.GitError, core.GlError) as e: |
| 110 | pprint.err(e) |
| 111 | return ERRORS_FOUND |
| 112 | except ErrorReturnCode as e: |
| 113 | pprint.err(e.stderr) |
| 114 | return ERRORS_FOUND |
| 115 | except: |
| 116 | pprint.err('Some internal error occurred') |
| 117 | pprint.err_exp( |
| 118 | 'If you want to help, see {0} for info on how to report bugs and ' |
| 119 | 'include the following information:\n\n{1}\n\n{2}'.format( |
| 120 | URL, __version__, traceback.format_exc())) |
| 121 | return INTERNAL_ERROR |
nothing calls this directly
no test coverage detected