Add ability to skip number of records
This commit is contained in:
		| @@ -13,6 +13,9 @@ ArgParser buildParser() { | ||||
|     ..addOption('destination', | ||||
|         abbr: 'd', help: 'OwnTracks Recorder server address') | ||||
|     ..addOption('user', abbr: 'u', help: 'User for OwnTrack record') | ||||
|     ..addOption('continue', | ||||
|         abbr: 'c', | ||||
|         help: 'The number of record to continue import from (Starting from 1)') | ||||
|     ..addFlag( | ||||
|       'help', | ||||
|       abbr: 'h', | ||||
| @@ -81,9 +84,34 @@ void main(List<String> arguments) async { | ||||
|  | ||||
|     final List<dynamic> failedList = []; | ||||
|  | ||||
|     final rawContinueFrom = results.option('continue'); | ||||
|  | ||||
|     final continueFrom = | ||||
|         rawContinueFrom == null ? 1 : int.parse(rawContinueFrom); | ||||
|  | ||||
|     int n = 1; | ||||
|  | ||||
|     if (continueFrom > recordsList.length) { | ||||
|       throw FormatException('There are only ${recordsList.length} in the list'); | ||||
|     } | ||||
|  | ||||
|     for (final record in recordsList) { | ||||
|       if (n < continueFrom) { | ||||
|         if (verbose) { | ||||
|           print(' '); | ||||
|           print('Record $n of ${recordsList.length} SKIPPED'); | ||||
|         } | ||||
|  | ||||
|         n++; | ||||
|  | ||||
|         continue; | ||||
|       } | ||||
|  | ||||
|       if (verbose) { | ||||
|         print(' '); | ||||
|         print('Record $n of ${recordsList.length}'); | ||||
|       } | ||||
|  | ||||
|       final Map<String, dynamic> payload = {'_type': 'location', 't': 'u'}; | ||||
|  | ||||
|       final recordProps = record['properties']; | ||||
| @@ -121,8 +149,6 @@ void main(List<String> arguments) async { | ||||
|       payload['conn'] = recordProps['connection']; | ||||
|  | ||||
|       if (verbose) { | ||||
|         print(' '); | ||||
|         print('Record $n of ${recordsList.length}'); | ||||
|         print(payload); | ||||
|       } | ||||
|  | ||||
| @@ -137,7 +163,6 @@ void main(List<String> arguments) async { | ||||
|       final url = '${results.option('destination')}/pub?u=$user&d=$device'; | ||||
|  | ||||
|       if (verbose) { | ||||
|         print(' '); | ||||
|         print('...Sending to: $url'); | ||||
|       } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user