- Add a system_parameters module to eryntools that implements some basic types and can write a cache to a file. - Add a system-parameters Python script that builds the cache. - Add init_system_parameters to zsh that exports an environment variable that points to the parameters file - Add an eryn.system-parameters.plist LaunchAgent file for running the script at regular intervals
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
| #!/usr/bin/env python3
 | |
| 
 | |
| import argparse
 | |
| from eryntools.dotfiles.system_parameters import CommandParameter, SystemParameters
 | |
| 
 | |
| 
 | |
| class HomebrewPrefix(CommandParameter):
 | |
|     def __init__(self):
 | |
|         super().__init__(['brew', '--prefix'])
 | |
| 
 | |
| 
 | |
| class XcodeSelectPrintPath(CommandParameter):
 | |
|     def __init__(self):
 | |
|         super().__init__(['xcode-select', '-p'])
 | |
| 
 | |
| 
 | |
| def main(argv):
 | |
|     parser = argparse.ArgumentParser(prog=argv[0])
 | |
|     parser.add_argument('-f', '--file', type=argparse.FileType('r'))
 | |
|     parser.add_argument('-o', '--output', type=argparse.FileType('w'), default=sys.stdout)
 | |
|     arguments = parser.parse_args(argv[1:])
 | |
| 
 | |
|     output_parameters = SystemParameters()
 | |
| 
 | |
|     if arguments.file:
 | |
|         output_parameters.load_from_file(arguments.file)
 | |
| 
 | |
|     parameters = {
 | |
|         'homebrew_prefix': HomebrewPrefix(),
 | |
|         'xcode_path': XcodeSelectPrintPath(),
 | |
|     }
 | |
| 
 | |
|     for name, parameter in parameters.items():
 | |
|         setattr(output_parameters, name, parameter)
 | |
| 
 | |
|     output_parameters.write_to_file(arguments.output)
 | |
| 
 | |
| 
 | |
| if __name__ == "__main__":
 | |
|     import sys
 | |
|     sys.exit(main(sys.argv) or 0)
 |