Conditions | 1 |
Total Lines | 93 |
Code Lines | 87 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | #!/usr/bin/env python3 |
||
56 | @classmethod |
||
57 | def get_parser(cls): |
||
58 | """Create command line argument parser""" |
||
59 | parser = argparse.ArgumentParser( |
||
60 | description='Simple read-only Thing 3 CLI.') |
||
61 | |||
62 | subparsers = parser.add_subparsers(help='', |
||
63 | metavar="command", |
||
64 | required=True, |
||
65 | dest="command") |
||
66 | subparsers.add_parser('inbox', |
||
67 | help='Shows inbox tasks') |
||
68 | subparsers.add_parser('today', |
||
69 | help='Shows todays tasks') |
||
70 | subparsers.add_parser('upcoming', |
||
71 | help='Shows upcoming tasks') |
||
72 | subparsers.add_parser('next', |
||
73 | help='Shows next tasks') |
||
74 | subparsers.add_parser('someday', |
||
75 | help='Shows someday tasks') |
||
76 | subparsers.add_parser('completed', |
||
77 | help='Shows completed tasks') |
||
78 | subparsers.add_parser('cancelled', |
||
79 | help='Shows cancelled tasks') |
||
80 | subparsers.add_parser('trashed', |
||
81 | help='Shows trashed tasks') |
||
82 | subparsers.add_parser('feedback', |
||
83 | help='Give feedback') |
||
84 | subparsers.add_parser('all', |
||
85 | help='Shows all tasks') |
||
86 | subparsers.add_parser('csv', |
||
87 | help='Exports tasks as CSV') |
||
88 | subparsers.add_parser('due', |
||
89 | help='Shows tasks with due dates') |
||
90 | subparsers.add_parser('headings', |
||
91 | help='Shows headings') |
||
92 | subparsers.add_parser('hours', |
||
93 | help='Shows hours planned today') |
||
94 | subparsers.add_parser('ical', |
||
95 | help='Shows tasks ordered by due date as iCal') |
||
96 | subparsers.add_parser('logbook', |
||
97 | help='Shows tasks completed today') |
||
98 | subparsers.add_parser('mostClosed', |
||
99 | help='Shows days when most tasks were closed') |
||
100 | subparsers.add_parser('mostCancelled', |
||
101 | help='Shows days when most tasks were cancelled') |
||
102 | subparsers.add_parser('mostTrashed', |
||
103 | help='Shows days when most tasks were trashed') |
||
104 | subparsers.add_parser('mostCreated', |
||
105 | help='Shows days when most tasks were created') |
||
106 | subparsers.add_parser('mostTasks', |
||
107 | help='Shows projects that have most tasks') |
||
108 | subparsers.add_parser('mostCharacters', |
||
109 | help='Shows tasks that have most characters') |
||
110 | subparsers.add_parser('nextish', |
||
111 | help='Shows all nextish tasks') |
||
112 | subparsers.add_parser('old', |
||
113 | help='Shows all old tasks') |
||
114 | subparsers.add_parser('projects', |
||
115 | help='Shows all projects') |
||
116 | subparsers.add_parser('repeating', |
||
117 | help='Shows all repeating tasks') |
||
118 | subparsers.add_parser('schedule', |
||
119 | help='Schedules an event using a template') |
||
120 | subparsers.add_parser('search', |
||
121 | help='Searches for a specific task') |
||
122 | subparsers.add_parser('stat', |
||
123 | help='Provides a number of statistics') |
||
124 | subparsers.add_parser('statcsv', |
||
125 | help='Exports some statistics as CSV') |
||
126 | subparsers.add_parser('subtasks', |
||
127 | help='Shows all subtasks') |
||
128 | subparsers.add_parser('tag', |
||
129 | help='Shows all tasks with the waiting for tag') |
||
130 | subparsers.add_parser('tags', |
||
131 | help='Shows all tags ordered by their usage') |
||
132 | subparsers.add_parser('waiting', |
||
133 | help='Shows all tasks with the waiting for tag') |
||
134 | |||
135 | parser.add_argument("-j", "--json", |
||
136 | action="store_true", default=False, |
||
137 | help="output as JSON", dest="json") |
||
138 | |||
139 | parser.add_argument("-c", "--csv", |
||
140 | action="store_true", default=False, |
||
141 | help="output as CSV", dest="csv") |
||
142 | |||
143 | parser.add_argument( |
||
144 | "--version", |
||
145 | action="version", |
||
146 | version="%(prog)s (version {version})".format(version=__version__)) |
||
147 | |||
148 | return parser |
||
149 | |||
174 |