Browse Source

xion: add verbose mode

master
dece 1 year ago
parent
commit
0f3a755083
  1. 6
      xion/__main__.py
  2. 5
      xion/xfconf.py
  3. 5
      xion/xion.py

6
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)

5
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

5
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.

Loading…
Cancel
Save