This commit is contained in:
anki-code 2020-03-14 10:51:21 +03:00
parent 7ef234af5a
commit 8924c16b89
9 changed files with 43 additions and 36 deletions

4
.gitignore vendored
View file

@ -8,7 +8,7 @@ squashfs-root
.pytest_cache/ .pytest_cache/
build/ build/
dist/ dist/
xonssh_xxh.egg-info/ xxh_xxh.egg-info/
venv/ venv/
# temporary files from vim and emacs # temporary files from vim and emacs
@ -25,4 +25,4 @@ venv/
.vscode/ .vscode/
# Mac # Mac
.DS_Store .DS_Store

View file

@ -1,15 +1,15 @@
<p align="center">You chosen a command shell and spent months to stuffed it with shortcuts and colors. But when you move from local to remote host using ssh you lose it all. The mission of xxh is to bring your favorite shell wherever you go through the ssh.</p> <p align="center">You chosen a command shell and spent months to stuffed it with shortcuts and colors. But when you move from local to remote host using ssh you lose it all. The mission of xxh is to bring your favorite shell wherever you go through the ssh.</p>
<p align="center"> <p align="center">
<a href="https://pypi.org/project/xonssh-xxh/" target="_blank"><img src="https://img.shields.io/pypi/v/xonssh-xxh.svg" alt="[release]"></a> <a href="https://pypi.org/project/xxh-xxh/" target="_blank"><img src="https://img.shields.io/pypi/v/xxh-xxh.svg" alt="[release]"></a>
<a href="https://asciinema.org/a/osSEzqnmH9pMYEZibNe2K7ZL7" target="_blank"><img alt="[asciinema demo]" src="https://img.shields.io/badge/demo-asciinema-grass"></a> <a href="https://asciinema.org/a/osSEzqnmH9pMYEZibNe2K7ZL7" target="_blank"><img alt="[asciinema demo]" src="https://img.shields.io/badge/demo-asciinema-grass"></a>
<a href="#plugins" target="_blank"><img alt="[plugins]" src="https://img.shields.io/badge/extensions-plugins-yellow"></a> <a href="#plugins" target="_blank"><img alt="[plugins]" src="https://img.shields.io/badge/extensions-plugins-yellow"></a>
<a href="https://gitter.im/xonssh-xxh/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge" target="_blank"><img alt="[gitter chat]" src="https://badges.gitter.im/xonssh-xxh/community.svg"></a> <a href="https://gitter.im/xonssh-xxh/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge" target="_blank"><img alt="[gitter chat]" src="https://badges.gitter.im/xonssh-xxh/community.svg"></a>
<img alt="[BSD license]" src="https://img.shields.io/pypi/l/xonssh-xxh"> <img alt="[BSD license]" src="https://img.shields.io/pypi/l/xxh-xxh">
</p> </p>
## Install or update ## Install or update
``` ```
python3 -m pip install --upgrade xonssh-xxh python3 -m pip install --upgrade xxh-xxh
``` ```
After install you can just using `xxh` command as replace `ssh` to connecting to the host because `xxh` has seamless support of basic `ssh` command arguments. After install you can just using `xxh` command as replace `ssh` to connecting to the host because `xxh` has seamless support of basic `ssh` command arguments.

View file

@ -1,8 +1,8 @@
import setuptools import setuptools
from xonssh_xxh.settings import global_settings from xxh_xxh.settings import global_settings
setuptools.setup( setuptools.setup(
name="xonssh-xxh", name="xxh-xxh",
version=global_settings['XXH_VERSION'], version=global_settings['XXH_VERSION'],
description="xxh is for using portable xonsh shell wherever you go through the ssh", description="xxh is for using portable xonsh shell wherever you go through the ssh",
url="https://github.com/xxh/xxh", url="https://github.com/xxh/xxh",
@ -19,7 +19,7 @@ setuptools.setup(
], ],
platforms='Unix-like', platforms='Unix-like',
scripts=['xxh','xxhp','xxh.zsh','xxh.xsh'], scripts=['xxh','xxhp','xxh.zsh','xxh.xsh'],
package_data={'xonssh_xxh':['*.xsh', '*.sh']}, package_data={'xxh_xxh':['*.xsh', '*.sh']},
packages=setuptools.find_packages(), packages=setuptools.find_packages(),
classifiers=[ classifiers=[
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",

8
xxh
View file

@ -347,7 +347,7 @@ class Xxh:
def main(self): def main(self):
self.create_xxh_env() self.create_xxh_env()
argp = argparse.ArgumentParser(description=f"Your favorite shell wherever you go through the ssh.\n{self.d2F0Y2ggLW4uMiB4eGggLWg()}", formatter_class=RawTextHelpFormatter, prefix_chars='-+') argp = argparse.ArgumentParser(description=f"Your favorite shell wherever you go through the ssh.\n{self.d2F0Y2ggLW4uMiB4eGggLWg()}", formatter_class=RawTextHelpFormatter, prefix_chars='-+')
argp.add_argument('--version', '-V', action='version', version=f"xonssh-xxh/{self.local_xxh_version}") argp.add_argument('--version', '-V', action='version', version=f"xxh/{self.local_xxh_version}")
argp.add_argument('-p', dest='ssh_port', help="Port to connect to on the remote host.") argp.add_argument('-p', dest='ssh_port', help="Port to connect to on the remote host.")
argp.add_argument('-l', dest='ssh_login', help="Specifies the user to log in as on the remote machine.") argp.add_argument('-l', dest='ssh_login', help="Specifies the user to log in as on the remote machine.")
argp.add_argument('-i', dest='ssh_private_key', help="File from which the identity (private key) for public key authentication is read.") argp.add_argument('-i', dest='ssh_private_key', help="File from which the identity (private key) for public key authentication is read.")
@ -674,8 +674,8 @@ if __name__ == '__main__':
this_file = __file__ this_file = __file__
sys.path.append(str(pf"{this_file}".absolute().parent)) sys.path.append(str(pf"{this_file}".absolute().parent))
import xonssh_xxh import xxh_xxh
from xonssh_xxh.settings import global_settings from xxh_xxh.settings import global_settings
xxh = Xxh(package_dir_path=pf"{xonssh_xxh.__file__}".parent, version=global_settings['XXH_VERSION']) xxh = Xxh(package_dir_path=pf"{xxh_xxh.__file__}".parent, version=global_settings['XXH_VERSION'])
xxh.main() xxh.main()

View file

@ -1,7 +1,7 @@
import sys, os import sys, os
global_settings = { global_settings = {
'XXH_VERSION': '0.5.7' 'XXH_VERSION': '0.5.8'
} }
if __name__ == "__main__": if __name__ == "__main__":

53
xxhp
View file

@ -39,45 +39,47 @@ class XxhPackage(object):
def install(self): def install(self):
parser = argparse.ArgumentParser(description='') parser = argparse.ArgumentParser(description='')
parser.add_argument('package', help=f"xxh-package") parser.add_argument('packages', nargs='+', help=f"xxh-package")
parser.add_argument('-v', '--verbose', action='store_true', help=f"Verbose mode") parser.add_argument('-v', '--verbose', action='store_true', help=f"Verbose mode")
parser.usage = parser.format_usage().replace('usage: xxhp ', 'xxhp install ') parser.usage = parser.format_usage().replace('usage: xxhp ', 'xxhp install ')
opt = parser.parse_args(sys.argv[2:]) opt = parser.parse_args(sys.argv[2:])
if not re.match('^[a-zA-Z-]+$', opt.package): for package in opt.packages:
self.eeprint(f'Invalid package name: {opt.package}') print(f'Install {package}')
if not re.match('^[a-zA-Z-]+$', package):
self.eeprint(f'Invalid package name: {package}')
subdir = self.package_subdir(opt.package) or self.eeprint(f"Unknown package: {opt.package}") subdir = self.package_subdir(package) or self.eeprint(f"Unknown package: {package}")
package_git_url = f'https://github.com/xxh/{opt.package}' package_git_url = f'https://github.com/xxh/{package}'
self.eprint(f"Git clone {package_git_url}") self.eprint(f"Git clone {package_git_url}")
package_dir = self.local_xxh_home_dir/'xxh'/subdir/opt.package package_dir = self.local_xxh_home_dir/'xxh'/subdir/package
r = ![git clone --depth 1 -q @(package_git_url) @(package_dir) 1>&2] r = ![git clone --depth 1 -q @(package_git_url) @(package_dir) 1>&2]
if r.returncode != 0: if r.returncode != 0:
self.eeprint(f'Git clone error') self.eeprint(f'If the package already exists try reinstall: xxhp ri <package>')
self.eprint(f"Build {opt.package}") self.eprint(f"Build {package}")
@(package_dir/'build.xsh') 1>&2 @(package_dir/'build.xsh') 1>&2
self.eprint(f"Installed {opt.package}") self.eprint(f"Installed {package_dir}")
def r(self): def r(self):
return self.remove() return self.remove()
def remove(self): def remove(self):
parser = argparse.ArgumentParser(description='') parser = argparse.ArgumentParser(description='')
parser.add_argument('package', help=f"xxh-package") parser.add_argument('packages', nargs='+', help=f"xxh-package")
parser.add_argument('-v', '--verbose', action='store_true', help=f"Verbose mode") parser.add_argument('-v', '--verbose', action='store_true', help=f"Verbose mode")
parser.usage = parser.format_usage().replace('usage: xxhp ', 'xxhp remove ') parser.usage = parser.format_usage().replace('usage: xxhp ', 'xxhp remove ')
opt = parser.parse_args(sys.argv[2:]) opt = parser.parse_args(sys.argv[2:])
subdir = self.package_subdir(opt.package) or self.eeprint(f"Unknown package: {opt.package}") for package in opt.packages:
package_dir = self.local_xxh_home_dir / 'xxh' / subdir / opt.package print(f'Remove {package}')
if package_dir.exists(): subdir = self.package_subdir(package) or self.eeprint(f"Unknown package: {package}")
rm -rf @(package_dir) package_dir = self.local_xxh_home_dir / 'xxh' / subdir / package
self.eprint(f"Removed {package_dir}") if package_dir.exists():
else: rm -rf @(package_dir)
self.eeprint(f"Package not found: {package_dir}") self.eprint(f"Removed {package_dir}")
def ri(self): def ri(self):
return self.reinstall() return self.reinstall()
@ -91,13 +93,18 @@ class XxhPackage(object):
def list(self): def list(self):
parser = argparse.ArgumentParser(description='') parser = argparse.ArgumentParser(description='')
parser.add_argument('packages', nargs='*', help=f"xxh-package")
parser.add_argument('-v', '--verbose', action='store_true', help=f"Verbose mode") parser.add_argument('-v', '--verbose', action='store_true', help=f"Verbose mode")
parser.usage = parser.format_usage().replace('usage: xxhp ', 'xxhp remove ') parser.usage = parser.format_usage().replace('usage: xxhp ', 'xxhp remove ')
opt = parser.parse_args(sys.argv[2:]) opt = parser.parse_args(sys.argv[2:])
packages_dir = (self.local_xxh_home_dir / 'xxh').glob('**/xxh-*') packages_dir = (self.local_xxh_home_dir / 'xxh').glob('**/xxh-*')
for p in sorted(packages_dir): for p in sorted(packages_dir):
print(p.name) if opt.packages:
if p.name in opt.packages:
print(p.name)
else:
print(p.name)
def package_subdir(self, name): def package_subdir(self, name):
if 'xxh-shell' in name: if 'xxh-shell' in name:
@ -108,4 +115,4 @@ class XxhPackage(object):
if __name__ == '__main__': if __name__ == '__main__':
XxhPackage() XxhPackage()