# Path: zfs_autobackup/LogConsole.py
# class LogConsole:
#     """Log-class that outputs to console, adding colors if needed"""
# 
#     def __init__(self, show_debug, show_verbose, color):
#         self.last_log = ""
#         self.show_debug = show_debug
#         self.show_verbose = show_verbose
#         self._progress_uncleared=False
# 
#         if color:
#             # try to use color, failback if colorama not available
#             self.colorama=False
#             try:
#                 import colorama
#                 global colorama
#                 self.colorama = True
#             except ImportError:
#                 pass
# 
#         else:
#             self.colorama=False
# 
#     def error(self, txt):
#         self.clear_progress()
#         if self.colorama:
#             print(colorama.Fore.RED + colorama.Style.BRIGHT + "! " + txt + colorama.Style.RESET_ALL, file=sys.stderr)
#         else:
#             print("! " + txt, file=sys.stderr)
#         sys.stderr.flush()
# 
#     def warning(self, txt):
#         self.clear_progress()
#         if self.colorama:
#             print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + "  NOTE: " + txt + colorama.Style.RESET_ALL)
#         else:
#             print("  NOTE: " + txt)
#         sys.stdout.flush()
# 
#     def verbose(self, txt):
#         if self.show_verbose:
#             self.clear_progress()
#             if self.colorama:
#                 print(colorama.Style.NORMAL + "  " + txt + colorama.Style.RESET_ALL)
#             else:
#                 print("  " + txt)
#             sys.stdout.flush()
# 
#     def debug(self, txt):
#         if self.show_debug:
#             self.clear_progress()
#             if self.colorama:
#                 print(colorama.Fore.GREEN + "# " + txt + colorama.Style.RESET_ALL)
#             else:
#                 print("# " + txt)
#             sys.stdout.flush()
# 
#     def progress(self, txt):
#         """print progress output to stderr (stays on same line)"""
#         self.clear_progress()
#         self._progress_uncleared=True
#         print(">>> {}\r".format(txt), end='', file=sys.stderr)
#         sys.stderr.flush()
# 
#     def clear_progress(self):
#         if self._progress_uncleared:
#             import colorama
#             print(colorama.ansi.clear_line(), end='', file=sys.stderr)
#             # sys.stderr.flush()
#             self._progress_uncleared=False


import argparse
import os.path
import sys
from .LogConsole import LogConsole



class CliBase(object):
    """Base class for all cli programs
    Overridden in subclasses that add stuff for the specific programs."""

    # also used by setup.py
    VERSION = "3.2-alpha2"
    HEADER = "{} v{} - (c)2022 E.H.Eefting (edwin@datux.nl)".format(os.path.basename(sys.argv[0]), VERSION)

    def __init__(self, argv, print_arguments=True):

        self.parser=self.get_parser()
        self.args = self.parse_args(argv)

        # helps with investigating failed regression tests:
        if print_arguments:

# Path: zfs_autobackup/LogConsole.py
# class LogConsole:
#     """Log-class that outputs to console, adding colors if needed"""
# 
#     def __init__(self, show_debug, show_verbose, color):
#         self.last_log = ""
#         self.show_debug = show_debug
#         self.show_verbose = show_verbose
#         self._progress_uncleared=False
# 
#         if color:
#             # try to use color, failback if colorama not available
#             self.colorama=False
#             try:
#                 import colorama
#                 global colorama
#                 self.colorama = True
#             except ImportError:
#                 pass
# 
#         else:
#             self.colorama=False
# 
#     def error(self, txt):
#         self.clear_progress()
#         if self.colorama:
#             print(colorama.Fore.RED + colorama.Style.BRIGHT + "! " + txt + colorama.Style.RESET_ALL, file=sys.stderr)
#         else:
#             print("! " + txt, file=sys.stderr)
#         sys.stderr.flush()
# 
#     def warning(self, txt):
#         self.clear_progress()
#         if self.colorama:
#             print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + "  NOTE: " + txt + colorama.Style.RESET_ALL)
#         else:
#             print("  NOTE: " + txt)
#         sys.stdout.flush()
# 
#     def verbose(self, txt):
#         if self.show_verbose:
#             self.clear_progress()
#             if self.colorama:
#                 print(colorama.Style.NORMAL + "  " + txt + colorama.Style.RESET_ALL)
#             else:
#                 print("  " + txt)
#             sys.stdout.flush()
# 
#     def debug(self, txt):
#         if self.show_debug:
#             self.clear_progress()
#             if self.colorama:
#                 print(colorama.Fore.GREEN + "# " + txt + colorama.Style.RESET_ALL)
#             else:
#                 print("# " + txt)
#             sys.stdout.flush()
# 
#     def progress(self, txt):
#         """print progress output to stderr (stays on same line)"""
#         self.clear_progress()
#         self._progress_uncleared=True
#         print(">>> {}\r".format(txt), end='', file=sys.stderr)
#         sys.stderr.flush()
# 
#     def clear_progress(self):
#         if self._progress_uncleared:
#             import colorama
#             print(colorama.ansi.clear_line(), end='', file=sys.stderr)
#             # sys.stderr.flush()
#             self._progress_uncleared=False


# Path: zfs_autobackup/CliBase.py
import argparse
import os.path
import sys
from .LogConsole import LogConsole




class CliBase(object):
    """Base class for all cli programs
    Overridden in subclasses that add stuff for the specific programs."""

    # also used by setup.py
    VERSION = "3.2-alpha2"
    HEADER = "{} v{} - (c)2022 E.H.Eefting (edwin@datux.nl)".format(os.path.basename(sys.argv[0]), VERSION)

    def __init__(self, argv, print_arguments=True):

        self.parser=self.get_parser()
        self.args = self.parse_args(argv)

        # helps with investigating failed regression tests:
        if print_arguments:

            print("ARGUMENTS: " + " ".join(argv))