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