diff --git a/src/bin/cmd.py b/src/bin/cmd.py index 4ff45d0..5487e06 100644 --- a/src/bin/cmd.py +++ b/src/bin/cmd.py @@ -33,13 +33,29 @@ def run(self, args: list = None, *arg, **kwargs): self.__version__() else: - - args = ' '.join(args) - stdout, stderr = subprocess.Popen( - args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True - ).communicate() - - if stdout.decode('utf-8') != '': - print(stdout.decode('utf-8')) - else: - self.ERRORS.command_not_found(stderr.decode('utf-8')) + if args == ['']: + self.__help__() + return + + process = subprocess.Popen( + args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True + ) + + for line in process.stdout: + print(line, end='') + for line in process.stderr: + self.ERRORS.os_command_not_found(process.stderr) + + # args = ' '.join(args) + # stdout, stderr = subprocess.Popen( + # args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True + # ).communicate() + + # if stdout.decode('utf-8') != '': + # print(stdout.decode('utf-8')) + + # else: + # self.ERRORS.command_not_found(stderr.decode('utf-8')) diff --git a/src/bin/help.py b/src/bin/help.py index 4b26433..8c0e3ef 100644 --- a/src/bin/help.py +++ b/src/bin/help.py @@ -36,8 +36,11 @@ def run(self, args: list = None, *arg, **kwargs): elif args[0] == '': # Listing all the commands in the bin directory and getting their short help # Getting all the files in the bin directory - lists_ = glob.glob1(os.path.join( - profile['BASE_DIR'], 'bin'), '*.py') + lists_ = glob.glob1( + os.path.join( + profile['BASE_DIR'], 'bin' + ), '*.py') + lists_ = [i.replace('.py', '') for i in lists_] # Removing the .py extension lists_.remove('__init__') # Removing the __init__.py file diff --git a/src/config.py b/src/config.py index 680c7ae..6846e35 100644 --- a/src/config.py +++ b/src/config.py @@ -44,7 +44,7 @@ "ANT_PATH": ANT_PATH, "SYSTEM_PATH": SYSTEM_PATH, "OPERATING_SYSTEM": OPERATING_SYSTEM, - "history": ".ant_history", + "history": ".ant_history", # history file name "aliases": { "cls": "clear", # cls is a windows command "dir": "ls", # dir is a windows command diff --git a/src/lib/backtrack.py b/src/lib/backtrack.py index 295c210..f2f2ecc 100644 --- a/src/lib/backtrack.py +++ b/src/lib/backtrack.py @@ -1,4 +1,5 @@ -from .userlib import stdlib +from lib.userlib import stdlib +from lib.userlib import SystemConfig class Errors: @@ -6,10 +7,14 @@ class Errors: def __init__(self) -> None: self.output = stdlib().error + self.os = SystemConfig().check_os() def command_not_found(self, command: str) -> None: self.output(f'Ant: {command}: command not found!') + def os_command_not_found(self, command: str) -> None: + self.output(f'Ant: {self.os}: {command}: command not found!') + def command_not_found_help(self, command: str) -> None: self.output( f'Ant: {command}: command not found. Try "help" for more information.' diff --git a/src/lib/core.py b/src/lib/core.py index e079784..4cfc03b 100644 --- a/src/lib/core.py +++ b/src/lib/core.py @@ -257,7 +257,7 @@ def execute(self, input_): try: # get modules from python path and reload them to get the latest changes file = import_module(f'bin.{input_.get_command()}') - # reload(file) + reload(file) file = getattr(file, 'Exclusive') file = file()