import 'dart:io';

import 'package:oto/cli/cli.dart';

class CommandConstant {
  static _CommandConstantBase? _instance;
  // ignore: library_private_types_in_public_api, non_constant_identifier_names
  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 {
    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';
  }
}
