Add extra checks related to flags

This commit is contained in:
Dennis Fokin 2023-10-20 08:16:19 +02:00
parent e3d216daa0
commit 556be0dbda
No known key found for this signature in database
GPG Key ID: 870B88256690D8BC
2 changed files with 26 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import 'package:logging/logging.dart';
import 'package:screen_retriever/screen_retriever.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:window_manager/window_manager.dart';
import 'package:yubico_authenticator/exception/initialization_exception.dart';
import '../app/app.dart';
import '../app/logging.dart';
@ -247,6 +248,10 @@ void _initLogging(List<String> argv) {
File? file;
if (logFileIndex != -1) {
final path = argv[logFileIndex + 1];
if (path.isEmpty) {
throw InitializationException(
'USAGE: Missing argument for option --log-file');
}
file = File(path);
}
Logger.root.onRecord.listen((record) {

View File

@ -0,0 +1,21 @@
/*
* Copyright (C) 2023 Yubico.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class InitializationException implements Exception {
final String message;
InitializationException(this.message);
}