mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-11 09:04:18 +00:00
refactor command "listfiles" to "files"
This commit is contained in:
@@ -420,11 +420,11 @@ def cmd_list_files(o):
|
|||||||
LOG.warn('unknown profile \"{}\"'.format(o.profile))
|
LOG.warn('unknown profile \"{}\"'.format(o.profile))
|
||||||
return
|
return
|
||||||
what = 'Dotfile(s)'
|
what = 'Dotfile(s)'
|
||||||
if o.listfiles_templateonly:
|
if o.files_templateonly:
|
||||||
what = 'Template(s)'
|
what = 'Template(s)'
|
||||||
LOG.emph('{} for profile \"{}\"\n'.format(what, o.profile))
|
LOG.emph('{} for profile \"{}\"\n'.format(what, o.profile))
|
||||||
for dotfile in o.dotfiles:
|
for dotfile in o.dotfiles:
|
||||||
if o.listfiles_templateonly:
|
if o.files_templateonly:
|
||||||
src = os.path.join(o.dotpath, dotfile.src)
|
src = os.path.join(o.dotpath, dotfile.src)
|
||||||
if not Templategen.is_template(src):
|
if not Templategen.is_template(src):
|
||||||
continue
|
continue
|
||||||
@@ -610,10 +610,10 @@ def main():
|
|||||||
LOG.dbg('running cmd: list')
|
LOG.dbg('running cmd: list')
|
||||||
cmd_list_profiles(o)
|
cmd_list_profiles(o)
|
||||||
|
|
||||||
elif o.cmd_listfiles:
|
elif o.cmd_files:
|
||||||
# list files for selected profile
|
# list files for selected profile
|
||||||
if o.debug:
|
if o.debug:
|
||||||
LOG.dbg('running cmd: listfiles')
|
LOG.dbg('running cmd: files')
|
||||||
cmd_list_files(o)
|
cmd_list_files(o)
|
||||||
|
|
||||||
elif o.cmd_install:
|
elif o.cmd_install:
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ Usage:
|
|||||||
dotdrop update [-VbfdkP] [-c <path>] [-p <profile>]
|
dotdrop update [-VbfdkP] [-c <path>] [-p <profile>]
|
||||||
[-i <pattern>...] [<path>...]
|
[-i <pattern>...] [<path>...]
|
||||||
dotdrop remove [-Vbfdk] [-c <path>] [-p <profile>] [<path>...]
|
dotdrop remove [-Vbfdk] [-c <path>] [-p <profile>] [<path>...]
|
||||||
dotdrop listfiles [-VbT] [-c <path>] [-p <profile>]
|
dotdrop files [-VbT] [-c <path>] [-p <profile>]
|
||||||
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
|
dotdrop detail [-Vb] [-c <path>] [-p <profile>] [<key>...]
|
||||||
dotdrop list [-Vb] [-c <path>]
|
dotdrop list [-Vb] [-c <path>]
|
||||||
dotdrop --help
|
dotdrop --help
|
||||||
@@ -190,7 +190,7 @@ class Options(AttrMonitor):
|
|||||||
"""apply cli args as attribute"""
|
"""apply cli args as attribute"""
|
||||||
# the commands
|
# the commands
|
||||||
self.cmd_list = self.args['list']
|
self.cmd_list = self.args['list']
|
||||||
self.cmd_listfiles = self.args['listfiles']
|
self.cmd_files = self.args['files']
|
||||||
self.cmd_install = self.args['install']
|
self.cmd_install = self.args['install']
|
||||||
self.cmd_compare = self.args['compare']
|
self.cmd_compare = self.args['compare']
|
||||||
self.cmd_import = self.args['import']
|
self.cmd_import = self.args['import']
|
||||||
@@ -212,8 +212,8 @@ class Options(AttrMonitor):
|
|||||||
sys.exit(USAGE)
|
sys.exit(USAGE)
|
||||||
self.import_link = OPT_LINK[link]
|
self.import_link = OPT_LINK[link]
|
||||||
|
|
||||||
# "listfiles" specifics
|
# "files" specifics
|
||||||
self.listfiles_templateonly = self.args['--template']
|
self.files_templateonly = self.args['--template']
|
||||||
# "install" specifics
|
# "install" specifics
|
||||||
self.install_force_action = self.args['--force-actions']
|
self.install_force_action = self.args['--force-actions']
|
||||||
self.install_temporary = self.args['--temp']
|
self.install_temporary = self.args['--temp']
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ set -e
|
|||||||
|
|
||||||
# test values have been correctly updated
|
# test values have been correctly updated
|
||||||
echo "========> test for updated entries"
|
echo "========> test for updated entries"
|
||||||
dotfiles=`cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 | grep -v '^ '`
|
dotfiles=`cd ${ddpath} | ${bin} files -c ${cfg} -p p1 | grep -v '^ '`
|
||||||
echo "${dotfiles}" | grep '^f_link ' | grep ', link: link)'
|
echo "${dotfiles}" | grep '^f_link ' | grep ', link: link)'
|
||||||
echo "${dotfiles}" | grep '^f_nolink ' | grep ', link: nolink)'
|
echo "${dotfiles}" | grep '^f_nolink ' | grep ', link: nolink)'
|
||||||
echo "${dotfiles}" | grep '^f_nolink1 ' | grep ', link: nolink)'
|
echo "${dotfiles}" | grep '^f_nolink1 ' | grep ', link: nolink)'
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ cd ${ddpath} | ${bin} import -c ${cfg} -p p2 \
|
|||||||
${tmpd}/sub/sub2/abc
|
${tmpd}/sub/sub2/abc
|
||||||
|
|
||||||
# count dotfiles for p2
|
# count dotfiles for p2
|
||||||
cnt=`cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p2 -b | grep '^f_' | wc -l`
|
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p2 -b | grep '^f_' | wc -l`
|
||||||
[ "${cnt}" != "4" ] && exit 1
|
[ "${cnt}" != "4" ] && exit 1
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
|
|||||||
@@ -116,12 +116,12 @@ echo "zzz" > ${tmps}/dotfiles/zzz
|
|||||||
echo "sub" > ${tmps}/dotfiles/sub
|
echo "sub" > ${tmps}/dotfiles/sub
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg1} -p p0 -V | grep f_def
|
cd ${ddpath} | ${bin} files -c ${cfg1} -p p0 -V | grep f_def
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg1} -p p1 -V | grep f_abc
|
cd ${ddpath} | ${bin} files -c ${cfg1} -p p1 -V | grep f_abc
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg1} -p p2 -V | grep f_def
|
cd ${ddpath} | ${bin} files -c ${cfg1} -p p2 -V | grep f_def
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg1} -p p3 -V | grep f_zzz
|
cd ${ddpath} | ${bin} files -c ${cfg1} -p p3 -V | grep f_zzz
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg1} -p pup -V | grep f_sub
|
cd ${ddpath} | ${bin} files -c ${cfg1} -p pup -V | grep f_sub
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg1} -p psubsub -V | grep f_sub
|
cd ${ddpath} | ${bin} files -c ${cfg1} -p psubsub -V | grep f_sub
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd}
|
rm -rf ${tmps} ${tmpd}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ _EOF
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V --link=link_children ${dt}
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 -V --link=link_children ${dt}
|
||||||
|
|
||||||
# check is set to link_children
|
# check is set to link_children
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "d_`basename ${dt}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "d_`basename ${dt}`")
|
||||||
echo ${line} | grep 'link: link_children'
|
echo ${line} | grep 'link: link_children'
|
||||||
|
|
||||||
# checks file exists in dotpath
|
# checks file exists in dotpath
|
||||||
|
|||||||
@@ -92,13 +92,13 @@ cd ${ddpath} | ${bin} compare -c ${cfg} -p p3
|
|||||||
cd ${ddpath} | ${bin} compare -c ${cfg} -p p0
|
cd ${ddpath} | ${bin} compare -c ${cfg} -p p0
|
||||||
|
|
||||||
# list
|
# list
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 | grep f_abc
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 | grep f_abc
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p2 | grep f_abc
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p2 | grep f_abc
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p3 | grep f_abc
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p3 | grep f_abc
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p0 | grep f_abc
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p0 | grep f_abc
|
||||||
|
|
||||||
# count
|
# count
|
||||||
cnt=`cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -b | grep '^f_' | wc -l`
|
cnt=`cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -b | grep '^f_' | wc -l`
|
||||||
[ "${cnt}" != "1" ] && exit 1
|
[ "${cnt}" != "1" ] && exit 1
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: nolink'
|
echo ${line} | grep 'link: nolink'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -113,8 +113,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: nolink'
|
echo ${line} | grep 'link: nolink'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -148,8 +148,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: nolink'
|
echo ${line} | grep 'link: nolink'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -183,8 +183,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=link
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=link
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: link'
|
echo ${line} | grep 'link: link'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -218,8 +218,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: link'
|
echo ${line} | grep 'link: link'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -253,8 +253,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: nolink'
|
echo ${line} | grep 'link: nolink'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -288,8 +288,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: nolink'
|
echo ${line} | grep 'link: nolink'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -323,8 +323,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V --link=nolink
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: nolink'
|
echo ${line} | grep 'link: nolink'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -356,8 +356,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} --link=link -p p1 ${df} -V
|
cd ${ddpath} | ${bin} import -c ${cfg} --link=link -p p1 ${df} -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "f_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: link'
|
echo ${line} | grep 'link: link'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -418,8 +418,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} --link=link_children -p p1 ${df} -V
|
cd ${ddpath} | ${bin} import -c ${cfg} --link=link_children -p p1 ${df} -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "d_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "d_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: link_children'
|
echo ${line} | grep 'link: link_children'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
@@ -459,8 +459,8 @@ df="${tmpd}/qwert"
|
|||||||
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
cd ${ddpath} | ${bin} import -c ${cfg} -p p1 ${df} -V
|
||||||
|
|
||||||
# checks
|
# checks
|
||||||
cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V
|
||||||
line=$(cd ${ddpath} | ${bin} listfiles -c ${cfg} -p p1 -V | grep "d_`basename ${df}`")
|
line=$(cd ${ddpath} | ${bin} files -c ${cfg} -p p1 -V | grep "d_`basename ${df}`")
|
||||||
echo ${line} | grep 'link: link_children'
|
echo ${line} | grep 'link: link_children'
|
||||||
|
|
||||||
# try to install
|
# try to install
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ def _fake_args():
|
|||||||
args['--force-actions'] = False
|
args['--force-actions'] = False
|
||||||
# cmds
|
# cmds
|
||||||
args['list'] = False
|
args['list'] = False
|
||||||
args['listfiles'] = False
|
args['files'] = False
|
||||||
args['install'] = False
|
args['install'] = False
|
||||||
args['compare'] = False
|
args['compare'] = False
|
||||||
args['import'] = False
|
args['import'] = False
|
||||||
|
|||||||
@@ -82,13 +82,13 @@ class TestListings(unittest.TestCase):
|
|||||||
cmd_importer(o)
|
cmd_importer(o)
|
||||||
o = load_options(confpath, profile)
|
o = load_options(confpath, profile)
|
||||||
|
|
||||||
# listfiles
|
# files
|
||||||
cmd_list_profiles(o)
|
cmd_list_profiles(o)
|
||||||
|
|
||||||
# list files
|
# list files
|
||||||
o.listfiles_templateonly = False
|
o.files_templateonly = False
|
||||||
cmd_list_files(o)
|
cmd_list_files(o)
|
||||||
o.listfiles_templateonly = True
|
o.files_templateonly = True
|
||||||
cmd_list_files(o)
|
cmd_list_files(o)
|
||||||
|
|
||||||
# details
|
# details
|
||||||
|
|||||||
Reference in New Issue
Block a user