-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwit_argparse.py
More file actions
47 lines (34 loc) · 2.17 KB
/
Copy pathwit_argparse.py
File metadata and controls
47 lines (34 loc) · 2.17 KB
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
import argparse
WitArguments = argparse.Namespace
class WitArgparse(object):
def __init__(self):
parser = argparse.ArgumentParser(prog="wit")
subparsers = parser.add_subparsers(dest="command", required=True, help="Wit command to execute")
# Create parser for the "init" command
subparsers.add_parser("init", help="initiate wit repository")
# Create parser for the "add" command
parser_add = subparsers.add_parser("add", help="add file to the staging area")
parser_add.add_argument("add_paths", action="append", nargs="*", help="file or directory to add",
metavar="path")
# Create parser for the "commit" command
parser_commit = subparsers.add_parser("commit", help="create a commit")
parser_commit.add_argument("message")
# Create parser for the "status" command
subparsers.add_parser("status", help="show current status")
# Create parser for the "checkout" command
parser_checkout = subparsers.add_parser("checkout", help="Checkout a specific commit")
parser_checkout.add_argument("commit_name", help="Branch name or commit id")
# Create parser for the "graph" command
subparsers.add_parser("graph", help="Show wit graph")
# Create parser for the "diff" command
parser_diff = subparsers.add_parser("diff", help="Show comparison between commits")
parser_diff_mutual_exclusive_group = parser_diff.add_mutually_exclusive_group()
parser_diff_mutual_exclusive_group.add_argument("--cached", action="store_true", dest="is_cached",
help="Use staging area as base for comparison")
parser_diff.add_argument("old_commit", nargs="?", metavar="commit",
help="Commit name to compare with")
parser_diff_mutual_exclusive_group.add_argument("new_commit", nargs="?", metavar="newer_commit",
help="Second commit to compare with")
self.parser = parser
def parse(self) -> WitArguments:
return self.parser.parse_args() # type: WitArguments