diff --git a/xion/__main__.py b/xion/__main__.py index 30cde08..4f13984 100644 --- a/xion/__main__.py +++ b/xion/__main__.py @@ -28,9 +28,13 @@ def main(): "-y", "--yes", action="store_true", help="Do not ask for confirmation" ) + argparser.add_argument( + "-v", "--verbose", action="store_true", + help="Verbose output" + ) args = argparser.parse_args() - xion = Xion(xq=args.xq_path) + xion = Xion(xq=args.xq_path, verbose=args.verbose) if args.export: channel, root, output = args.export tree = xion.build_tree(channel, root) diff --git a/xion/xfconf.py b/xion/xfconf.py index 4e1ee0c..69f1b40 100644 --- a/xion/xfconf.py +++ b/xion/xfconf.py @@ -17,12 +17,15 @@ class Xfconf: "gchararray": "string", } - def __init__(self, xq=None): + def __init__(self, xq=None, verbose=False): self._xq = xq or self.find_xq() + self.verbose = verbose def xq(self, command, print_failures=True): """Run a xion-query command and return its output or None on error.""" command.insert(0, self._xq) + if self.verbose: + print(f"$ {' '.join(command)}") try: return subprocess.check_output( command, stderr=subprocess.STDOUT diff --git a/xion/xion.py b/xion/xion.py index 9ba01cd..deb47fe 100644 --- a/xion/xion.py +++ b/xion/xion.py @@ -6,8 +6,9 @@ from xion.xfconf import Xfconf class Xion: """Manipulate Xfconf settings trees.""" - def __init__(self, xq=None): - self.xfconf = Xfconf(xq=xq) + def __init__(self, xq=None, verbose=False): + self.xfconf = Xfconf(xq=xq, verbose=verbose) + self.verbose = verbose def build_tree(self, channel, root="/"): """Return a dict of properties in this channel, filtering on root.