import sys
from gitaccount import GitAccount


def main():
    if len(sys.argv) < 2:
        print("""Usage:
    gitcloner.py [OPTION] [NAME]

    OPTIONS:
        -u  - for user repositories
        -o  - for organization repositories
    NAME:
        Username or Organization Name
""")
        sys.exit(1)

    args = sys.argv[1:3]
    repoType, name = args
    if repoType == '-u':
        repoType = 'user'
    elif repoType == '-o':
        repoType = 'org'
    else:
        raise ValueError()

    account = GitAccount(repoType, name)
    account.cloneRepos()


if __name__ == '__main__':
    main()

import sys
import argparse
from gitaccount import GitAccount


def main():
    parser = argparse.ArgumentParser(
             prog='gitcloner',
             description='Clone all the repositories from a github user/org\naccount to the current directory')
    group = parser.add_mutually_exclusive_group()

    group.add_argument('-u', '--user', help='For user accounts [DEFAULT]',
                   action='store_true')
    group.add_argument('-o', '--org', help='For organization accounts',
                       action='store_true')
    parser.add_argument('name', help='name of the user / organization')

    args = parser.parse_args()

    if not(args.user or args.org):
        args.user = True
        print('Default account type is user account')

    if args.user:
        print('Username: {}'.format(args.name))
        accType = 'user'
    else:
        print('Organization: {}'.format(args.name))
        accType = 'org'

    account = GitAccount(accType, args.name)
    account.cloneRepos()


if __name__ == '__main__':
    main()

Use argparse instead of sys.argv
Use argparse instead of sys.argv

  import sys
+ import argparse
  from gitaccount import GitAccount
  
  
  def main():
-     if len(sys.argv) < 2:
-         print("""Usage:
-     gitcloner.py [OPTION] [NAME]
+     parser = argparse.ArgumentParser(
+              prog='gitcloner',
+              description='Clone all the repositories from a github user/org\naccount to the current directory')
+     group = parser.add_mutually_exclusive_group()
  
+     group.add_argument('-u', '--user', help='For user accounts [DEFAULT]',
+                    action='store_true')
+     group.add_argument('-o', '--org', help='For organization accounts',
+                        action='store_true')
+     parser.add_argument('name', help='name of the user / organization')
-     OPTIONS:
-         -u  - for user repositories
-         -o  - for organization repositories
-     NAME:
-         Username or Organization Name
- """)
-         sys.exit(1)
  
-     args = sys.argv[1:3]
-     repoType, name = args
-     if repoType == '-u':
+     args = parser.parse_args()
+ 
+     if not(args.user or args.org):
+         args.user = True
+         print('Default account type is user account')
+ 
+     if args.user:
+         print('Username: {}'.format(args.name))
-         repoType = 'user'
+         accType = 'user'
-     elif repoType == '-o':
-         repoType = 'org'
      else:
-         raise ValueError()
+         print('Organization: {}'.format(args.name))
+         accType = 'org'
  
-     account = GitAccount(repoType, name)
+     account = GitAccount(accType, args.name)
      account.cloneRepos()
  
  
  if __name__ == '__main__':
      main()
  
Use argparse instead of sys.argv
## Code Before:
import sys
from gitaccount import GitAccount


def main():
    if len(sys.argv) < 2:
        print("""Usage:
    gitcloner.py [OPTION] [NAME]

    OPTIONS:
        -u  - for user repositories
        -o  - for organization repositories
    NAME:
        Username or Organization Name
""")
        sys.exit(1)

    args = sys.argv[1:3]
    repoType, name = args
    if repoType == '-u':
        repoType = 'user'
    elif repoType == '-o':
        repoType = 'org'
    else:
        raise ValueError()

    account = GitAccount(repoType, name)
    account.cloneRepos()


if __name__ == '__main__':
    main()

## Instruction:
Use argparse instead of sys.argv
## Code After:
import sys
import argparse
from gitaccount import GitAccount


def main():
    parser = argparse.ArgumentParser(
             prog='gitcloner',
             description='Clone all the repositories from a github user/org\naccount to the current directory')
    group = parser.add_mutually_exclusive_group()

    group.add_argument('-u', '--user', help='For user accounts [DEFAULT]',
                   action='store_true')
    group.add_argument('-o', '--org', help='For organization accounts',
                       action='store_true')
    parser.add_argument('name', help='name of the user / organization')

    args = parser.parse_args()

    if not(args.user or args.org):
        args.user = True
        print('Default account type is user account')

    if args.user:
        print('Username: {}'.format(args.name))
        accType = 'user'
    else:
        print('Organization: {}'.format(args.name))
        accType = 'org'

    account = GitAccount(accType, args.name)
    account.cloneRepos()


if __name__ == '__main__':
    main()
