xion: add verbose mode
This commit is contained in:
parent
ae0edfcaa0
commit
0f3a755083
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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…
Reference in a new issue