Skip to content

Commit 6dae2c6

Browse files
authored
add 'add' and 'subtract' functionality
1 parent 60437e5 commit 6dae2c6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

xRange.py

+18
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ def main(program):
201201
def_parser.add_argument('--start', default=None, help='First index in range', type=int, required=True)
202202
def_parser.add_argument('--stop', default=None, help='Last index in range. Must be larger than start', type=int, required=True)
203203

204+
# PARSER : ADD
205+
a_parser = subparsers.add_parser('add', help='Define the range by first index', parents=[parent_parser])
206+
a_parser.add_argument('--add', default=None, help='Length of extract', type=int, required=True)
207+
a_parser.add_argument('--start', default=None, help='First index in range', type=int, required=True)
208+
209+
# PARSER : SUBTRACT
210+
s_parser = subparsers.add_parser('subtract', help='Define the range by last index', parents=[parent_parser])
211+
s_parser.add_argument('--stop', default=None, help='Last index in range', type=int, required=True)
212+
s_parser.add_argument('--sub', default=None, help='Length of extract', type=int, required=True)
213+
204214
args = parent_parser.parse_args()
205215

206216
# CHECK FOR VALID INPUT
@@ -215,6 +225,14 @@ def main(program):
215225
start = args.start
216226
stop = args.stop
217227

228+
if program == 'add':
229+
start = args.start
230+
stop = start + args.add
231+
232+
if program == 'subtract':
233+
stop = args.stop
234+
start = stop - args.sub
235+
218236
extract_range(args, start, stop, outdir)
219237

220238

0 commit comments

Comments
 (0)