createSnappCliDirectory method

Future<Directory> createSnappCliDirectory()

Creates a directory in the user's home directory to store the snapp_cli related files like ssh keys

Implementation

Future<Directory> createSnappCliDirectory() async {
  logger.detail('try to create SnappCli directory');

  final String homePath = hostPlatform.homePath;
  final String snappCliDirectoryPath = '$homePath/.snapp_cli';

  final snappCliDirectory = Directory(snappCliDirectoryPath);

  if (!(await snappCliDirectory.exists())) {
    logger.detail('SnappCli directory does not exist, creating it now');
    return await snappCliDirectory.create();
  }

  logger.detail('SnappCli directory already exists');

  return snappCliDirectory;
}