writeCompletionConfigForShell method
Adds a reference for the command-specific config file created on writeCompletionScriptForCommand the the global completion config file.
Implementation
@visibleForTesting
void writeCompletionConfigForShell(String rootCommand) {
final configuration = this.configuration!;
final completionConfigDirPath = completionConfigDir.path;
final configPath = path.join(
completionConfigDirPath,
configuration.completionConfigForShellFileName,
);
logger.info('Adding config for $rootCommand config entry to $configPath');
final configFile = File(configPath);
if (!configFile.existsSync()) {
logger.info('No file found at $configPath, creating one now');
configFile.createSync();
}
if (ScriptConfigurationEntry(rootCommand).existsIn(configFile)) {
logger.warn(
'A config entry for $rootCommand was already found on $configPath.',
);
return;
}
final commandScriptName = '$rootCommand.${configuration.shell.name}';
_sourceScriptOnFile(
configFile: configFile,
scriptName: rootCommand,
scriptPath: path.join(completionConfigDirPath, commandScriptName),
);
}