set function
Starts setting build configurations for the flutter application according to given configuration.
Configuration is a map of build configurations and their values.
You can specify it in the following way:
package_rename_config
key inpubspec.yaml
:
package_rename_config:
...
package_rename_config.yaml
file at the root of the project:
package_rename_config:
...
Implementation
void set(List<String> args) {
try {
print(_majorTaskDoneLine);
if (!_configFileExists()) throw _PackageRenameErrors.filesNotFound;
// Create args parser to get flavour flag and its value
final parser = ArgParser()
..addOption(
'path',
abbr: 'p',
help: 'The path for the config file',
)
..addOption(
'flavour',
abbr: 'f',
help: 'The flavour of the configuration to be used.',
aliases: ['flavor'],
)
..addFlag(
'help',
abbr: 'h',
negatable: false,
help: 'Prints out available command usages',
);
final results = parser.parse(args);
if (results.wasParsed('help')) {
print(_packageRenameCommands);
print(parser.usage);
exit(0);
}
final flavour = results['flavour'] as String?;
final path = results['path'] as String?;
final config = _getConfig(flavour: flavour, configFile: path);
_setAndroidConfigurations(config['android']);
_setIOSConfigurations(config['ios']);
_setLinuxConfigurations(config['linux']);
_setMacOSConfigurations(config['macos']);
_setWebConfigurations(config['web']);
_setWindowsConfigurations(config['windows']);
print(_successMessage);
} on _PackageRenameException catch (e) {
print(e.message);
exit(e.code);
} catch (e) {
print(e);
exit(255);
}
}