working on some installer stuff I suppose

master
Jordan Orelli 2 years ago
parent 2a285a3006
commit 1485516e8c

@ -3,3 +3,5 @@ if !has('nvim')
endif endif
nnoremap <F5> :Cargo run<CR> nnoremap <F5> :Cargo run<CR>
let g:rustfmt_autosave = 1

@ -30,3 +30,5 @@ Vundle.vim=AppData/Local/nvim/bundle/Vundle.vim
packer.nvim=AppData/Local/nvim-data/site/pack/packer/start/packer.nvim packer.nvim=AppData/Local/nvim-data/site/pack/packer/start/packer.nvim
nvim/lua=AppData/Local/nvim/lua nvim/lua=AppData/Local/nvim/lua
cargo-config.toml=.cargo/config.toml cargo-config.toml=.cargo/config.toml
[cargo:gitui]

@ -16,6 +16,7 @@ from installer import host
from installer.options import Options from installer.options import Options
from installer import log from installer import log
from installer import targets from installer import targets
from installer import sections
class Installer: class Installer:
""" """
@ -32,6 +33,17 @@ class Installer:
print("You are not admin: admin is required on Windows") print("You are not admin: admin is required on Windows")
sys.exit(1) sys.exit(1)
config = self.options.config
for section_name in config.sections():
try:
T = self.parse_section_name(section_name)
except ValueError as e:
print(f"error reading section: {e}")
continue
section = T.from_section(section_name, **config[section_name])
print(f"Section: {section}")
section.run()
print("linking in home files") print("linking in home files")
home = self.options.config['home'] home = self.options.config['home']
home_files = filter(None, home['files'].splitlines()) home_files = filter(None, home['files'].splitlines())
@ -95,3 +107,9 @@ class Installer:
target_path = pathlib.Path(target_name) target_path = pathlib.Path(target_name)
print(f"Map {source_path} to {target_path}") print(f"Map {source_path} to {target_path}")
self.map_file(source_path, target_path) self.map_file(source_path, target_path)
def parse_section_name(self, section_name):
if section_name == "home":
return sections.Home
raise ValueError(f"unprocessable section name: {section_name}")

@ -0,0 +1,22 @@
"""
sections defines our various config sections
"""
import pathlib
class Home:
"""
the [home] section maps files within the home directory
"""
@classmethod
def from_section(Cls, name, **section):
v = Cls()
if raw_files := section.get('files'):
v.files = filter(None, raw_files.splitlines())
else:
v.files = None
return v
def run(self):
pass
Loading…
Cancel
Save