make zotsh even more useful with hidden rootdir sites, "host foo@bar.com" connects to the webdav server on bar.com and changes directory to 'foo'.

This commit is contained in:
nobody 2021-08-29 01:21:01 -07:00
parent 655ba0f191
commit 20bc5cd5ea
2 changed files with 20 additions and 2 deletions

View file

@ -24,6 +24,10 @@ The ability to browse remote WebDAV repositories outside your own server is not
cd username
OR you can connect to the site using
host username@hostname
if you know a username on that site and if they have given you the requisite permission *or* their directory contains publicly readable content.
----
@ -41,10 +45,12 @@ Commands
host <hostname>
Authenticate to 'hostname' and switch to it
host <username@hostname>
Authenticate to 'hostname' and switch to it and automatically cd to the 'username' directory
cd <dirname|..>
change remote dir
ls [path] [-a] [-l] [-d]
list remote files in current dir if 'path' not defined
-a list all, show hidden dot-files

View file

@ -141,9 +141,15 @@ class ZotSH(object):
return self.davclient.download(args[0], args[1])
def cmd_host(self, *args):
ruser = ''
if (len(args)==0):
return
newhostname = args[0]
i = newhostname.find('@')
if (i != (-1)):
ruser = newhostname[0:i]
newhostname = newhostname[i+1:]
newhost = "https://%s/" % newhostname
if newhostname == "~" or newhost == SERVER:
# back to home server
@ -165,7 +171,13 @@ class ZotSH(object):
self.hostname = newhostname
self.session = session_remote
if (ruser):
try:
self.do('cd', *[ruser])
except easywebdav.client.OperationFailed as e:
print(e)
def cmd_pwd(self, *args):
return "%s%s" % ( self.davclient.baseurl, self.davclient.cwd )