Skip to content

Commit

Permalink
add help info
Browse files Browse the repository at this point in the history
  • Loading branch information
nosarthur committed Feb 6, 2018
1 parent 3715242 commit effbde6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
24 changes: 10 additions & 14 deletions gita/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def update_repos(new_paths=None):
:rtype: `dict` of repo name to repo absolute path
"""
path_file = os.path.join(
os.path.expanduser('~'), '.gita_path')
path_file = os.path.join(os.path.expanduser('~'), '.gita_path')
if os.path.exists(path_file):
with open(path_file) as f:
paths = set(f.read().split(os.pathsep))
Expand Down Expand Up @@ -45,31 +44,28 @@ def f_ls(args):
def f_rm(args):
repos = update_repos()
del repos[args.repo]
path_file = os.path.join(
os.path.expanduser('~'), '.gita_path')
path_file = os.path.join(os.path.expanduser('~'), '.gita_path')
if os.path.exists(path_file):
with open(path_file, 'w') as f:
f.write(os.pathsep.join(repos.values()))


def main(argv=None):
p = argparse.ArgumentParser()
subparsers = p.add_subparsers()
p = argparse.ArgumentParser(prog='gita')
subparsers = p.add_subparsers(title='sub-commands', help='additional help with sub-command -h')

p_ls = subparsers.add_parser('ls', description='display all repos')
p_ls.add_argument('repo', nargs='?',
choices=update_repos(),
help="show directory of the chosen repo")
p_ls = subparsers.add_parser('ls', help='display all repos')
p_ls.add_argument('repo', nargs='?', choices=update_repos(),
help="show path of the chosen repo")
p_ls.set_defaults(func=f_ls)

p_add = subparsers.add_parser('add')
p_add = subparsers.add_parser('add', help='add repositories')
p_add.add_argument('repo', nargs='+',
help="add repositories")
p_add.set_defaults(func=f_add)

p_rm = subparsers.add_parser('rm')
p_rm.add_argument('repo', nargs='?',
choices=update_repos(),
p_rm = subparsers.add_parser('rm', help='remove repository')
p_rm.add_argument('repo', nargs='?', choices=update_repos(),
help="remove the chosen repo")
p_rm.set_defaults(func=f_rm)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='gita',
version='0.1.dev0',
version='0.1',
description='Manage multiple git repos',
packages=['gita',],
url='https://github.com/nosarthur/gita.git',
Expand Down

0 comments on commit effbde6

Please sign in to comment.