mirror of
https://github.com/Foltik/dotfiles
synced 2025-01-23 15:13:25 -05:00
Add dump and enable units flags
This commit is contained in:
parent
90a2adcbd3
commit
4984a66e5e
43
install.py
43
install.py
@ -3,7 +3,9 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import curses
|
import curses
|
||||||
|
import distutils.dir_util
|
||||||
import lib.deploy as deploy
|
import lib.deploy as deploy
|
||||||
|
from pathlib import Path
|
||||||
from lib.parse import parse
|
from lib.parse import parse
|
||||||
from lib.package import Category, Package
|
from lib.package import Category, Package
|
||||||
from lib.menu import Menu, ChecklistMenu
|
from lib.menu import Menu, ChecklistMenu
|
||||||
@ -17,6 +19,18 @@ def run():
|
|||||||
for package in category.packages:
|
for package in category.packages:
|
||||||
configure(package)
|
configure(package)
|
||||||
|
|
||||||
|
def dump(package):
|
||||||
|
print(package.name + ':')
|
||||||
|
for k, v in package.getattrs():
|
||||||
|
print(' ' + k, v)
|
||||||
|
|
||||||
|
def lookup_package(name):
|
||||||
|
try:
|
||||||
|
package = next(p for p in parsed_packages if p.name == name or p.alias == name)
|
||||||
|
return package
|
||||||
|
except StopIteration:
|
||||||
|
raise Exception('Package not found: ' + name)
|
||||||
|
|
||||||
class App:
|
class App:
|
||||||
def __init__(self, stdscreen):
|
def __init__(self, stdscreen):
|
||||||
self.screen = stdscreen
|
self.screen = stdscreen
|
||||||
@ -39,6 +53,8 @@ class App:
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser(description="Foltik's super cool dotfiles install script")
|
parser = argparse.ArgumentParser(description="Foltik's super cool dotfiles install script")
|
||||||
parser.add_argument('packages', metavar='pkg', type=str, nargs='*')
|
parser.add_argument('packages', metavar='pkg', type=str, nargs='*')
|
||||||
|
parser.add_argument('--all', '-a', dest='all', action='store_const', const=True,
|
||||||
|
help='Run on all packages')
|
||||||
|
|
||||||
actions = [
|
actions = [
|
||||||
('--deploy', '-d', deploy.deploy, 'Run all options'),
|
('--deploy', '-d', deploy.deploy, 'Run all options'),
|
||||||
@ -47,7 +63,9 @@ if __name__ == '__main__':
|
|||||||
('--import-config', '-C', deploy.import_config, 'Import package config'),
|
('--import-config', '-C', deploy.import_config, 'Import package config'),
|
||||||
('--script', '-x', deploy.run_script, 'Run package script'),
|
('--script', '-x', deploy.run_script, 'Run package script'),
|
||||||
('--units', '-u', deploy.export_units, 'Export and enable package units'),
|
('--units', '-u', deploy.export_units, 'Export and enable package units'),
|
||||||
('--import-units', '-U', deploy.import_units, 'Import package units')
|
('--import-units', '-U', deploy.import_units, 'Import package units'),
|
||||||
|
('--enable-units', '-e', deploy.enable_units, 'Enable package units'),
|
||||||
|
('--dump', '-l', dump, 'Dump package attributes')
|
||||||
]
|
]
|
||||||
|
|
||||||
for action in actions:
|
for action in actions:
|
||||||
@ -55,18 +73,19 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.packages == []:
|
if args.actions != None and args.packages == [] and args.all == True:
|
||||||
|
for package in parsed_packages:
|
||||||
|
for action in args.actions:
|
||||||
|
action(package)
|
||||||
|
elif args.actions != None and args.packages != []:
|
||||||
|
for package in args.packages:
|
||||||
|
for action in args.actions:
|
||||||
|
action(lookup_package(package))
|
||||||
|
else:
|
||||||
os.environ.setdefault('ESCDELAY', '0')
|
os.environ.setdefault('ESCDELAY', '0')
|
||||||
curses.wrapper(App)
|
curses.wrapper(App)
|
||||||
if run_installer:
|
if run_installer:
|
||||||
run()
|
run()
|
||||||
else:
|
|
||||||
for action in args.actions:
|
if Path('git').is_dir():
|
||||||
for package in args.packages:
|
distutils.dir_util.remove_tree('git')
|
||||||
try:
|
|
||||||
pkg = next(pkg for pkg in parsed_packages if pkg.name == package)
|
|
||||||
print(str(action) + ': ' + str(pkg))
|
|
||||||
action(pkg)
|
|
||||||
except StopIteration:
|
|
||||||
print('Package not found: ' + package)
|
|
||||||
sys.exit(1)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user