123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import argparse
- import commands.clone, commands.search, commands.show, commands.update
- if __name__ == '__main__':
- # Arguments
- # --------------------------------------
- parser = argparse.ArgumentParser()
- parser.add_argument( "--indexfile",
- type = str,
- default = "/var/cache/gitlist/index",
- help = "The name of the index to create" )
- parser.add_argument( "--gitreposdir",
- type = str,
- default = "/etc/gitlist/gitrepos.d"
- help = "The name of the directory where the " \
- "gitrepos files are" )
- # --------------------------------------
- subparsers = parser.add_subparsers( dest = "command",
- title = "commands" )
- # Clone
- sp_clone = subparsers.add_parser( "clone",
- help = "Clone a git repository" )
- commands.clone.init(sp_clone)
-
- # Help
- sp_help = subparsers.add_parser( "help",
- help = "Print this help" )
- # Search
- sp_search = subparsers.add_parser( "search",
- help = "Print this search" )
- commands.search.init(sp_search)
- # Show
- sp_show = subparsers.add_parser( "show",
- help = "Print this show" )
- commands.show.init(sp_show)
- # Update
- sp_update = subparsers.add_parser( "update",
- help = "Print this update" )
- commands.update.init(sp_update)
- args = parser.parse_args()
- # Logging
- # --------------------------------------
- logger = logging.getLogger("gitlist")
- log.setLevel(logging.DEBUG)
- # Console handler
- loghandler_console = logging.StreamHandler()
- loghandler_console.setLevel(logging.WARNING)
- # Adjust for verbosity
- if(args.verbose):
- loghandler_console.setLevel(logging.DEBUG)
- # Format for console (no need for time)
- logformatter_console = logging.Formatter("%(name)s:%(levelname)s: %(message)s")
- # And we're set!
- loghandler_console.setFormatter(logformatter_console)
- logger.addHandler(loghandler_console)
- # Script
- # --------------------------------------
- # Start with help
- if args.command in [ "help", None ]:
- parser.print_help()
- exit() # TODO add return codes?
- # CLONE
- # opt: proto, ask
- # - Resolve name to giturl from cache ## NOT GITURL, GITREPO FILE
- # - if ask: get gitrepo and ask before cloning ? ## NO ASK ALWAYS
- # - launch git with right params ; tries proto in order
- # SEARCH
- # opt: thourough
- # - grep through cache file (tags), or gitrepos file if thourough
- # - get corresponding gitrepos to print desc?
- # SHOW
- # - grep through cache file
- # - get corresponding gitrepo
- # - show gitrepo
- # UPDATE
- # - parse all gitrepo files one by one
- # - generate cache file
- # - cache file format is: shortname gitreponame tags...
|