| Conditions | 1 |
| Total Lines | 111 |
| Code Lines | 102 |
| 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 |
||
| 64 | @classmethod |
||
| 65 | def get_parser(cls): |
||
| 66 | """Create command line argument parser""" |
||
| 67 | parser = argparse.ArgumentParser( |
||
| 68 | description='Simple read-only Thing 3 CLI.') |
||
| 69 | |||
| 70 | subparsers = parser.add_subparsers(help='', |
||
| 71 | metavar="command", |
||
| 72 | required=True, |
||
| 73 | dest="command") |
||
| 74 | subparsers.add_parser('inbox', |
||
| 75 | help='Shows inbox tasks') |
||
| 76 | subparsers.add_parser('today', |
||
| 77 | help='Shows todays tasks') |
||
| 78 | subparsers.add_parser('upcoming', |
||
| 79 | help='Shows upcoming tasks') |
||
| 80 | subparsers.add_parser('next', |
||
| 81 | help='Shows next tasks') |
||
| 82 | subparsers.add_parser('backlog', |
||
| 83 | help='Shows backlog tasks') |
||
| 84 | subparsers.add_parser('completed', |
||
| 85 | help='Shows completed tasks') |
||
| 86 | subparsers.add_parser('cancelled', |
||
| 87 | help='Shows cancelled tasks') |
||
| 88 | subparsers.add_parser('trashed', |
||
| 89 | help='Shows trashed tasks') |
||
| 90 | subparsers.add_parser('feedback', |
||
| 91 | help='Give feedback') |
||
| 92 | subparsers.add_parser('all', |
||
| 93 | help='Shows all tasks') |
||
| 94 | subparsers.add_parser('csv', |
||
| 95 | help='Exports tasks as CSV') |
||
| 96 | subparsers.add_parser('areas', |
||
| 97 | help='Shows all areas') |
||
| 98 | subparsers.add_parser('opml', |
||
| 99 | help='Exports tasks as OPML') |
||
| 100 | subparsers.add_parser('due', |
||
| 101 | help='Shows tasks with due dates') |
||
| 102 | subparsers.add_parser('empty', |
||
| 103 | help='Shows projects that are empty') |
||
| 104 | subparsers.add_parser('headings', |
||
| 105 | help='Shows headings') |
||
| 106 | subparsers.add_parser('hours', |
||
| 107 | help='Shows hours planned today') |
||
| 108 | subparsers.add_parser('ical', |
||
| 109 | help='Shows tasks ordered by due date as iCal') |
||
| 110 | subparsers.add_parser('lint', |
||
| 111 | help='Shows tasks that float around') |
||
| 112 | subparsers.add_parser('logbook', |
||
| 113 | help='Shows tasks completed today') |
||
| 114 | subparsers.add_parser('mostClosed', |
||
| 115 | help='Shows days when most tasks were closed') |
||
| 116 | subparsers.add_parser('mostCancelled', |
||
| 117 | help='Shows days when most tasks were cancelled') |
||
| 118 | subparsers.add_parser('mostTrashed', |
||
| 119 | help='Shows days when most tasks were trashed') |
||
| 120 | subparsers.add_parser('mostCreated', |
||
| 121 | help='Shows days when most tasks were created') |
||
| 122 | subparsers.add_parser('mostTasks', |
||
| 123 | help='Shows projects that have most tasks') |
||
| 124 | subparsers.add_parser('mostCharacters', |
||
| 125 | help='Shows tasks that have most characters') |
||
| 126 | subparsers.add_parser('nextish', |
||
| 127 | help='Shows all nextish tasks') |
||
| 128 | subparsers.add_parser('old', |
||
| 129 | help='Shows all old tasks') |
||
| 130 | subparsers.add_parser('projects', |
||
| 131 | help='Shows all projects') |
||
| 132 | subparsers.add_parser('repeating', |
||
| 133 | help='Shows all repeating tasks') |
||
| 134 | subparsers.add_parser('schedule', |
||
| 135 | help='Schedules an event using a template') |
||
| 136 | subparsers.add_parser('search', |
||
| 137 | help='Searches for a specific task') |
||
| 138 | subparsers.add_parser('stat', |
||
| 139 | help='Provides a number of statistics') |
||
| 140 | subparsers.add_parser('statcsv', |
||
| 141 | help='Exports some statistics as CSV') |
||
| 142 | subparsers.add_parser('subtasks', |
||
| 143 | help='Shows all subtasks') |
||
| 144 | subparsers.add_parser('tag', |
||
| 145 | help='Shows all tasks with the waiting for tag') |
||
| 146 | subparsers.add_parser('tags', |
||
| 147 | help='Shows all tags ordered by their usage') |
||
| 148 | subparsers.add_parser('waiting', |
||
| 149 | help='Shows all tasks with the waiting for tag') |
||
| 150 | |||
| 151 | parser.add_argument("-j", "--json", |
||
| 152 | action="store_true", default=False, |
||
| 153 | help="output as JSON", dest="json") |
||
| 154 | |||
| 155 | parser.add_argument("-c", "--csv", |
||
| 156 | action="store_true", default=False, |
||
| 157 | help="output as CSV", dest="csv") |
||
| 158 | |||
| 159 | parser.add_argument("-o", "--opml", |
||
| 160 | action="store_true", default=False, |
||
| 161 | help="output as OPML", dest="opml") |
||
| 162 | |||
| 163 | parser.add_argument("-a", "--anonymize", |
||
| 164 | action="store_true", default=False, |
||
| 165 | help="anonymize output", dest="anonymize") |
||
| 166 | |||
| 167 | parser.add_argument( |
||
| 168 | "--version", |
||
| 169 | action="version", |
||
| 170 | version="%(prog)s (version {version})".format(version=__version__)) |
||
| 171 | |||
| 172 | argcomplete.autocomplete(parser) |
||
| 173 | |||
| 174 | return parser |
||
| 175 | |||
| 210 |