mirror of
https://github.com/xxh/xxh
synced 2024-11-26 21:50:25 +00:00
0.7.4
This commit is contained in:
parent
471b3a1b1d
commit
6f2a2b3d05
3 changed files with 29 additions and 24 deletions
|
@ -64,7 +64,7 @@ xxh myhost +s bash-zero +I xxh-plugin-bash-vim # install bash plugin before
|
||||||
xxh myhost +if +q # install without questions in quiet mode
|
xxh myhost +if +q # install without questions in quiet mode
|
||||||
xxh myhost +hh /tmp/xxh +hhr # upload xxh to myhost:/tmp/xxh and remove it after disconnect
|
xxh myhost +hh /tmp/xxh +hhr # upload xxh to myhost:/tmp/xxh and remove it after disconnect
|
||||||
```
|
```
|
||||||
To reusing arguments there is `~/.xxh/.xxhc` [yaml](https://en.wikipedia.org/wiki/YAML) config:
|
To reusing arguments there is `~/.config/xxh/config.xxhc` (`$XDG_CONFIG_HOME`) [yaml](https://en.wikipedia.org/wiki/YAML) config:
|
||||||
```yaml
|
```yaml
|
||||||
hosts:
|
hosts:
|
||||||
myhost: # settings for myhost
|
myhost: # settings for myhost
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Example of xxh config file ~/.xxh/.xxhc
|
# Example of xxh config file `~/.config/xxh/config.xxhc` (`$XDG_CONFIG_HOME`)
|
||||||
#
|
#
|
||||||
# The `hosts` section contains host names or regular expression patterns to match hostname.
|
# The `hosts` section contains host names or regular expression patterns to match hostname.
|
||||||
#
|
#
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
# Example for `+if` mode below.
|
# Example for `+if` mode below.
|
||||||
#
|
#
|
||||||
#--------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------
|
||||||
# Example ~/.xxh/.xxhc
|
# Example `~/.config/xxh/config.xxhc` (`$XDG_CONFIG_HOME`)
|
||||||
#--------------------------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------------------------
|
||||||
#hosts:
|
#hosts:
|
||||||
# myhost: # settings for myhost
|
# myhost: # settings for myhost
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
# +I: xxh-shell-zsh # install xxh-shell before connect
|
# +I: xxh-shell-zsh # install xxh-shell before connect
|
||||||
# +I: xxh-plugin-zsh-ohmyzsh # install xxh-plugin before connect
|
# +I: xxh-plugin-zsh-ohmyzsh # install xxh-plugin before connect
|
||||||
# +e: ZSH_THEME="clean" # set ohmyzsh theme
|
# +e: ZSH_THEME="clean" # set ohmyzsh theme
|
||||||
|
# +hhh: "~" # use user default home directory on host (/home/user instead of /home/user/.xxh)
|
||||||
#
|
#
|
||||||
# "company-.*": # for all hosts by regex pattern
|
# "company-.*": # for all hosts by regex pattern
|
||||||
# +if: # don't asking about install (++install-force)
|
# +if: # don't asking about install (++install-force)
|
||||||
|
|
|
@ -6,7 +6,7 @@ from urllib.parse import urlparse
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from .shell import *
|
from .shell import *
|
||||||
|
|
||||||
XXH_VERSION = '0.7.3'
|
XXH_VERSION = '0.7.4'
|
||||||
|
|
||||||
class xxh:
|
class xxh:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -16,7 +16,7 @@ class xxh:
|
||||||
self.local_xxh_version = XXH_VERSION
|
self.local_xxh_version = XXH_VERSION
|
||||||
self.ssh_command = 'ssh'
|
self.ssh_command = 'ssh'
|
||||||
self.local_xxh_home = p('~/.xxh')
|
self.local_xxh_home = p('~/.xxh')
|
||||||
self.config_file = self.generate_config_filepath()
|
self.config_file = self.get_config_filepath()
|
||||||
self.host_xxh_home = '~/.xxh'
|
self.host_xxh_home = '~/.xxh'
|
||||||
self.shell = self.get_current_shell()
|
self.shell = self.get_current_shell()
|
||||||
self.short_shell_name = self.shell.split('-')[2]
|
self.short_shell_name = self.shell.split('-')[2]
|
||||||
|
@ -54,12 +54,10 @@ class xxh:
|
||||||
def eeprint(self, *args, **kwargs):
|
def eeprint(self, *args, **kwargs):
|
||||||
eeprint(*args, **kwargs)
|
eeprint(*args, **kwargs)
|
||||||
|
|
||||||
@staticmethod
|
def get_config_filepath(self):
|
||||||
def generate_config_filepath():
|
|
||||||
if os.environ.get('XDG_CONFIG_HOME'):
|
if os.environ.get('XDG_CONFIG_HOME'):
|
||||||
return p(os.environ['XDG_CONFIG_HOME']) / 'xxh' / 'xxhc'
|
return p(os.environ['XDG_CONFIG_HOME']) / 'xxh/config.xxhc'
|
||||||
else:
|
return p(os.environ['HOME']) / '.config/xxh/config.xxhc'
|
||||||
return p(os.environ['HOME']) / '.config' / 'xxh' / 'xxhc'
|
|
||||||
|
|
||||||
def get_current_shell(self):
|
def get_current_shell(self):
|
||||||
if 'SHELL' in os.environ:
|
if 'SHELL' in os.environ:
|
||||||
|
@ -345,7 +343,9 @@ class xxh:
|
||||||
config_file = p(self.config_file)
|
config_file = p(self.config_file)
|
||||||
sample_config_file = self.package_dir_path / 'config.xxhc'
|
sample_config_file = self.package_dir_path / 'config.xxhc'
|
||||||
if not config_file.exists() and sample_config_file.exists():
|
if not config_file.exists() and sample_config_file.exists():
|
||||||
self.S(f'cp {sample_config_file} {config_file}')
|
if not self.quiet:
|
||||||
|
eprint(f'Create sample config file in {config_file}')
|
||||||
|
self.S(f'mkdir -p {config_file.parent} && cp {sample_config_file} {config_file}')
|
||||||
|
|
||||||
def d2F0Y2ggLW4uMiB4eGggLWg(self):
|
def d2F0Y2ggLW4uMiB4eGggLWg(self):
|
||||||
def randint(a, b):
|
def randint(a, b):
|
||||||
|
@ -535,15 +535,13 @@ class xxh:
|
||||||
print(f'Sourcing files extracted to {cdir}')
|
print(f'Sourcing files extracted to {cdir}')
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
self.local_xxh_home = p(f"{opt.local_xxh_home}")
|
|
||||||
self.config_file = self.local_xxh_home/'.xxhc'
|
|
||||||
self.create_xxh_env()
|
|
||||||
xxh_config_file = p(opt.xxh_config)
|
|
||||||
|
|
||||||
if self.config_file != xxh_config_file and not xxh_config_file.exists():
|
opt.xxh_config = p(opt.xxh_config)
|
||||||
self.eeprint(f'Config does not exist: {xxh_config_file}')
|
if self.config_file != opt.xxh_config:
|
||||||
else:
|
if not opt.xxh_config.exists():
|
||||||
self.config_file = xxh_config_file
|
self.eeprint(f'Config not found in {opt.xxh_config}')
|
||||||
|
else:
|
||||||
|
self.config_file = opt.xxh_config
|
||||||
|
|
||||||
self.quiet = opt.quiet
|
self.quiet = opt.quiet
|
||||||
arg_q = ['-q'] if self.quiet else []
|
arg_q = ['-q'] if self.quiet else []
|
||||||
|
@ -589,19 +587,25 @@ class xxh:
|
||||||
self.verbose = opt.verbose
|
self.verbose = opt.verbose
|
||||||
self.vverbose = opt.vverbose
|
self.vverbose = opt.vverbose
|
||||||
|
|
||||||
packages_opration = False
|
|
||||||
|
packages_opration = opt.install_xxh_packages \
|
||||||
|
or opt.reinstall_xxh_packages \
|
||||||
|
or opt.remove_xxh_packages \
|
||||||
|
or opt.list_xxh_packages \
|
||||||
|
or opt.list_xxh_packages == []
|
||||||
|
|
||||||
|
if packages_opration or self.destination_exists:
|
||||||
|
self.local_xxh_home = p(opt.local_xxh_home)
|
||||||
|
self.create_xxh_env()
|
||||||
|
|
||||||
if opt.install_xxh_packages:
|
if opt.install_xxh_packages:
|
||||||
installed = self.packages_install(opt.install_xxh_packages)
|
installed = self.packages_install(opt.install_xxh_packages)
|
||||||
packages_opration = True
|
|
||||||
if opt.reinstall_xxh_packages:
|
if opt.reinstall_xxh_packages:
|
||||||
reinstalled = self.packages_reinstall(opt.reinstall_xxh_packages)
|
reinstalled = self.packages_reinstall(opt.reinstall_xxh_packages)
|
||||||
packages_opration = True
|
|
||||||
if opt.remove_xxh_packages:
|
if opt.remove_xxh_packages:
|
||||||
removed = self.packages_remove(opt.remove_xxh_packages)
|
removed = self.packages_remove(opt.remove_xxh_packages)
|
||||||
packages_opration = True
|
|
||||||
if opt.list_xxh_packages or opt.list_xxh_packages == []:
|
if opt.list_xxh_packages or opt.list_xxh_packages == []:
|
||||||
found = self.packages_list(opt.list_xxh_packages)
|
found = self.packages_list(opt.list_xxh_packages)
|
||||||
packages_opration = True
|
|
||||||
|
|
||||||
if not self.destination_exists:
|
if not self.destination_exists:
|
||||||
if packages_opration:
|
if packages_opration:
|
||||||
|
|
Loading…
Reference in a new issue