Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

#!/usr/bin/env python3 

 

"""Plugin for Git.""" 

 

import argparse 

import logging 

 

from . import PLUGIN, NAME, __version__ 

from . import common 

from .cli import _get_command, _run_command 

 

PROG = 'git ' + PLUGIN 

DESCRIPTION = "Use {} (v{}) to install repostories.".format(NAME, __version__) 

 

log = logging.getLogger(__name__) 

 

 

def main(args=None): 

"""Process command-line arguments and run the Git plugin.""" 

 

# Main parser 

parser = argparse.ArgumentParser(prog=PROG, description=DESCRIPTION) 

parser.add_argument( 

'-f', '--force', action='store_true', 

help="overwrite uncommitted changes in dependencies", 

) 

parser.add_argument( 

'-c', '--clean', action='store_true', 

help="delete ignored files when updating dependencies", 

) 

 

# Options group 

group = parser.add_mutually_exclusive_group() 

shared = dict(action='store_const', dest='command') 

 

# Update option 

group.add_argument( 

'-u', '--update', const='update', 

help="update dependencies to the latest versions", **shared 

) 

parser.add_argument('-a', '--all', action='store_true', dest='recurse', 

help="include nested dependencies when updating") 

parser.add_argument('-L', '--no-lock', 

action='store_false', dest='lock', default=True, 

help="skip recording of versions for later reinstall") 

 

# Display option 

group.add_argument( 

'-l', '--list', const='list', 

help="display the current version of each dependency", **shared 

) 

 

# Uninstall option 

group.add_argument( 

'-x', '--uninstall', const='uninstall', 

help="delete all installed dependencies", **shared 

) 

 

# Parse arguments 

namespace = parser.parse_args(args=args) 

 

# Modify arguments to match CLI interface 

63 ↛ 64line 63 didn't jump to line 64, because the condition on line 63 was never true if not namespace.command: 

namespace.command = 'install' 

namespace.name = [] 

namespace.root = None 

namespace.depth = None 

namespace.allow_dirty = True 

namespace.fetch = True 

 

# Configure logging 

common.configure_logging() 

 

# Run the program 

function, args, kwargs = _get_command(None, namespace) 

_run_command(function, args, kwargs) 

 

 

if __name__ == '__main__': # pragma: no cover (manual test) 

main()