1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 18:34:48 +00:00

wrap conf and args into a new Options class

This commit is contained in:
deadc0de6
2019-02-10 20:59:14 +01:00
parent 88c730157d
commit c82cc56dcf
10 changed files with 435 additions and 313 deletions

View File

@@ -10,9 +10,9 @@ import string
import random
import tempfile
from dotdrop.config import Cfg
from dotdrop.utils import *
from dotdrop.options import Options
from dotdrop.linktypes import LinkTypes
from dotdrop.utils import *
TMPSUFFIX = '.dotdrop'
@@ -81,20 +81,56 @@ def create_dir(path):
return path
def load_config(confpath, profile):
def _fake_args():
args = {}
args['--verbose'] = False
args['--no-banner'] = False
args['--dry'] = False
args['--force'] = False
args['--nodiff'] = False
args['--showdiff'] = True
args['--inv-link'] = False
args['--template'] = False
args['--temp'] = False
args['<key>'] = []
args['--dopts'] = ''
args['--file'] = []
args['--ignore'] = []
args['<path>'] = []
args['--key'] = False
args['--ignore'] = []
args['--show-patch'] = False
# cmds
args['list'] = False
args['listfiles'] = False
args['install'] = False
args['compare'] = False
args['import'] = False
args['update'] = False
args['detail'] = False
return args
def load_options(confpath, profile):
"""Load the config file from path"""
conf = Cfg(confpath)
opts = conf.get_settings()
opts['dry'] = False
opts['profile'] = profile
opts['safe'] = True
opts['installdiff'] = True
opts['link'] = LinkTypes.NOLINK.value
opts['showdiff'] = True
opts['debug'] = True
opts['dopts'] = ''
opts['variables'] = {}
return conf, opts
# create the fake args (bypass docopt)
args = _fake_args()
args['--cfg'] = confpath
args['--profile'] = profile
# and get the options
# TODO need to patch options
o = Options(args=args)
o.profile = profile
o.dry = False
o.profile = profile
o.safe = True
o.installdiff = True
o.link = LinkTypes.NOLINK.value
o.showdiff = True
o.debug = True
o.dopts = ''
o.variables = {}
return o
def get_path_strip_version(path):