72 lines
1.5 KiB
Dart
72 lines
1.5 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:oto_cli/cli/cli.dart';
|
|
|
|
class CommandConstant {
|
|
static _CommandConstantBase? _instance;
|
|
// ignore: library_private_types_in_public_api
|
|
static _CommandConstantBase? get OS {
|
|
if (_instance == null) {
|
|
if (Platform.isMacOS) {
|
|
_instance = _CommandConstantOSX();
|
|
} else if (Platform.isLinux) {
|
|
_instance = _CommandConstantLinux();
|
|
} else {
|
|
_instance = _CommandConstantWindows();
|
|
}
|
|
}
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
class _CommandConstantBase {
|
|
String get installPath {
|
|
var userPath = Platform.environment['HOME'];
|
|
return '';
|
|
}
|
|
|
|
String get installFilePath {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
class _CommandConstantOSX extends _CommandConstantBase {
|
|
@override
|
|
String get installPath {
|
|
var userPath = Platform.environment['HOME'];
|
|
return '$userPath/Applications/${CLI.serviceName}/';
|
|
}
|
|
|
|
@override
|
|
String get installFilePath {
|
|
return '$installPath${CLI.serviceName}';
|
|
}
|
|
}
|
|
|
|
class _CommandConstantLinux extends _CommandConstantBase {
|
|
@override
|
|
String get installPath {
|
|
return '';
|
|
}
|
|
|
|
@override
|
|
String get installFilePath {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
class _CommandConstantWindows extends _CommandConstantBase {
|
|
final windowRoamingPath = '\\AppData\\Roaming\\';
|
|
|
|
@override
|
|
String get installPath {
|
|
var userPath = Platform.environment['UserProfile'];
|
|
return '$userPath$windowRoamingPath${CLI.serviceName}\\';
|
|
}
|
|
|
|
@override
|
|
String get installFilePath {
|
|
return '$installPath${CLI.serviceName}.exe';
|
|
;
|
|
}
|
|
}
|