This commit is contained in:
Richard 2023-12-25 08:05:18 +01:00
parent bc8d565fc3
commit 1ba10260c0
4 changed files with 11 additions and 2 deletions

View File

@ -8,5 +8,6 @@ RUN pip3 install -r requirements.txt
ADD --chown=user . /app ADD --chown=user . /app
RUN chmod +x /app/main.py RUN chmod +x /app/main.py
VOLUME /data VOLUME /data
#ENTRYPOINT bash
ENTRYPOINT [ "python3", "/app/main.py"] ENTRYPOINT [ "python3", "/app/main.py"]
CMD ["-s", "/data/store.npt"] CMD ["-s", "/data/store.npt", "-x", "/data/cmd.hst"]

View File

@ -12,5 +12,6 @@ def main(args):
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('-s', '--store-file', default='data/store.npt') parser.add_argument('-s', '--store-file', default='data/store.npt')
parser.add_argument('-x', '--history-file', default='data/cmd.hst')
args = parser.parse_args() args = parser.parse_args()
main(args) main(args)

View File

@ -8,12 +8,17 @@ from .util import *
from time import sleep, time from time import sleep, time
from threading import Thread from threading import Thread
from nullptr.central_command import CentralCommand from nullptr.central_command import CentralCommand
import readline
import os
class CommandError(Exception): class CommandError(Exception):
pass pass
class Commander(CommandLine): class Commander(CommandLine):
def __init__(self, store_file='data/store.npt'): def __init__(self, store_file='data/store.npt', hist_file = 'data/cmd.hst'):
self.hist_file = hist_file
if os.path.isfile(hist_file):
readline.read_history_file(hist_file)
self.store = Store(store_file) self.store = Store(store_file)
self.agent = self.select_agent() self.agent = self.select_agent()
self.api = Api(self.store, self.agent) self.api = Api(self.store, self.agent)
@ -26,6 +31,7 @@ class Commander(CommandLine):
def handle_eof(self): def handle_eof(self):
self.store.close() self.store.close()
readline.write_history_file(self.hist_file)
print("Goodbye!") print("Goodbye!")
def prompt(self): def prompt(self):

View File

@ -1 +1,2 @@
requests requests
readline