mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
Added vimdiff
This commit is contained in:
parent
51ad456753
commit
0b3e813dd1
2 changed files with 21 additions and 4 deletions
|
@ -2,6 +2,8 @@
|
|||
Updated:
|
||||
- For empty arguments
|
||||
- Checks for invalid options
|
||||
Added:
|
||||
- Vimdiff in the slpkg_new-configs file (Thanks to tkor)
|
||||
|
||||
Updated:
|
||||
- Dialog text help for dependencies
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
import sys
|
||||
import shutil
|
||||
import difflib
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
|
@ -74,7 +75,7 @@ class NewConfig:
|
|||
f"{'':>2}({self.byellow}O{self.endc})verwrite all old files with the new ones.\n"
|
||||
f"{'':>5}The old files will be stored with the suffix '.orig'.\n"
|
||||
f"{'':>2}({self.byellow}R{self.endc})emove all '.new' files.\n"
|
||||
f"{'':>2}({self.byellow}P{self.endc})rompt K, O, R, D selection for every single file.\n")
|
||||
f"{'':>2}({self.byellow}P{self.endc})rompt K, O, R, D, V selection for every single file.\n")
|
||||
|
||||
self.menu()
|
||||
|
||||
|
@ -152,11 +153,14 @@ class NewConfig:
|
|||
def prompt(self):
|
||||
""" Prompt K, O, R selection for every single file. """
|
||||
print(f"\n{'':>2}({self.byellow}K{self.endc})eep, ({self.byellow}O{self.endc})verwrite, "
|
||||
f"({self.byellow}R{self.endc})emove, ({self.byellow}D{self.endc})iff\n")
|
||||
f"({self.byellow}R{self.endc})emove, ({self.byellow}D{self.endc})iff, "
|
||||
f"({self.byellow}V{self.endc})imdiff\n")
|
||||
|
||||
if self.slpkg_config_new.is_file():
|
||||
make = input(f'{self.bgreen}{self.slpkg_config_new}{self.endc} - '
|
||||
f'({self.byellow}K{self.endc}/{self.byellow}O{self.endc}/'
|
||||
f'{self.byellow}R{self.endc}/{self.byellow}D{self.endc}): ')
|
||||
f'{self.byellow}R{self.endc}/{self.byellow}D{self.endc}/'
|
||||
f'{self.byellow}V{self.endc}): ')
|
||||
|
||||
if make.lower() == 'k':
|
||||
pass
|
||||
|
@ -169,11 +173,14 @@ class NewConfig:
|
|||
print() # new line
|
||||
if make.lower() == 'd':
|
||||
self.diff_files(self.slpkg_config_new, self.slpkg_config)
|
||||
if make.lower() == 'v':
|
||||
self.vimdiff(self.slpkg_config_new, self.slpkg_config)
|
||||
|
||||
if self.blacklist_config_new.is_file():
|
||||
make = input(f'{self.bgreen}{self.blacklist_config_new}{self.endc} - '
|
||||
f'({self.byellow}K{self.endc}/{self.byellow}O{self.endc}/'
|
||||
f'{self.byellow}R{self.endc}/{self.byellow}D{self.endc}): ')
|
||||
f'{self.byellow}R{self.endc}/{self.byellow}D{self.endc}/'
|
||||
f'{self.byellow}V{self.endc}): ')
|
||||
|
||||
if make.lower() == 'k':
|
||||
pass
|
||||
|
@ -186,6 +193,8 @@ class NewConfig:
|
|||
print() # new line
|
||||
if make.lower() == 'd':
|
||||
self.diff_files(self.blacklist_config_new, self.blacklist_config)
|
||||
if make.lower() == 'v':
|
||||
self.vimdiff(self.blacklist_config_new, self.blacklist_config)
|
||||
|
||||
@staticmethod
|
||||
def diff_files(file1, file2):
|
||||
|
@ -201,6 +210,12 @@ class NewConfig:
|
|||
for line in diff:
|
||||
print(line, end='')
|
||||
|
||||
@staticmethod
|
||||
def vimdiff(file1, file2):
|
||||
output = subprocess.call(f'vimdiff {file1} {file2}', shell=True)
|
||||
if output != 0:
|
||||
raise SystemExit(output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = sys.argv
|
||||
|
|
Loading…
Add table
Reference in a new issue