mirror of
				https://github.com/kewlfft/ansible-aur.git
				synced 2025-11-04 01:52:31 +03:00 
			
		
		
		
	Split main into testable functions
This commit is contained in:
		@@ -218,7 +218,7 @@ def install_packages(module, packages, use, state, aur_only):
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
def make_module():
 | 
			
		||||
    module = AnsibleModule(
 | 
			
		||||
        argument_spec={
 | 
			
		||||
            'name': {
 | 
			
		||||
@@ -274,6 +274,12 @@ def main():
 | 
			
		||||
    if params.get('upgrade', False) and use == 'makepkg':
 | 
			
		||||
        module.fail_json(msg="Upgrade cannot be used with the helper 'makepkg'.")
 | 
			
		||||
 | 
			
		||||
    return module, use
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def apply_module(module, use):
 | 
			
		||||
    params = module.params
 | 
			
		||||
 | 
			
		||||
    if module.check_mode:
 | 
			
		||||
        check_packages(module, params['name'])
 | 
			
		||||
    elif params.get('upgrade', False):
 | 
			
		||||
@@ -282,5 +288,10 @@ def main():
 | 
			
		||||
        install_packages(module, params['name'], use, params['state'], params['aur_only'])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    module, use = make_module()
 | 
			
		||||
    apply_module(module, use)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    main()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user