add "edit" command to open config file

This commit is contained in:
Gilles Grandou 2023-12-04 23:46:19 +01:00
parent 39019f5df0
commit 7dc36feaa3

View File

@ -216,7 +216,8 @@ def main():
parser.description = 'run commands on any distribution' parser.description = 'run commands on any distribution'
parser.add_argument('osname', parser.add_argument('osname',
help = 'distribution name to run on, ' help = 'distribution name to run on, '
'"list" to dump all available distributions') '"list" to dump all available distributions, '
'"edit" to open the current config file in a text editor.')
parser.epilog = '(c) 2021 Gilles Grandou <gilles@grandou.net>' parser.epilog = '(c) 2021 Gilles Grandou <gilles@grandou.net>'
parser.add_argument('-v', '--verbose', action='store_true', parser.add_argument('-v', '--verbose', action='store_true',
@ -246,6 +247,10 @@ def main():
print(' {}'.format(o)) print(' {}'.format(o))
print() print()
return 0 return 0
elif args.osname == 'edit':
cmd = [ 'xdg-open', conf_file ]
ret = subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL);
return 0
if args.link: if args.link:
make_osname_link(sys.argv[0], args.osname) make_osname_link(sys.argv[0], args.osname)