fix issue where saving config is not executed
This commit is contained in:
parent
9d4ccd92ad
commit
be9e6c3d31
1 changed files with 9 additions and 4 deletions
11
minitch.py
11
minitch.py
|
@ -2,6 +2,7 @@
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
|
import atexit
|
||||||
from shutil import unpack_archive
|
from shutil import unpack_archive
|
||||||
import yaml
|
import yaml
|
||||||
import mergedeep
|
import mergedeep
|
||||||
|
@ -110,7 +111,10 @@ def parser_run(args):
|
||||||
os.chdir(config['games'][args.game_id]['path'])
|
os.chdir(config['games'][args.game_id]['path'])
|
||||||
os.chmod(config['games'][args.game_id]['executable'], 755)
|
os.chmod(config['games'][args.game_id]['executable'], 755)
|
||||||
game_args = config['games'][args.game_id]['args'] if 'args' in config['games'][args.game_id] else []
|
game_args = config['games'][args.game_id]['args'] if 'args' in config['games'][args.game_id] else []
|
||||||
subprocess.run([config['games'][args.game_id]['executable'], *game_args])
|
try:
|
||||||
|
subprocess.run([config['games'][args.game_id]['executable'], *game_args])
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
||||||
def parser_list(args):
|
def parser_list(args):
|
||||||
global config
|
global config
|
||||||
|
@ -120,6 +124,9 @@ def parser_list(args):
|
||||||
def main():
|
def main():
|
||||||
read_config()
|
read_config()
|
||||||
|
|
||||||
|
# Write config on exit
|
||||||
|
atexit.register(write_config)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Tiny little itch.io client')
|
parser = argparse.ArgumentParser(description='Tiny little itch.io client')
|
||||||
subparsers = parser.add_subparsers(title='subcommands', description='valid subcommands', help='additional help')
|
subparsers = parser.add_subparsers(title='subcommands', description='valid subcommands', help='additional help')
|
||||||
|
|
||||||
|
@ -163,7 +170,5 @@ def main():
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
parser.error('too few arguments')
|
parser.error('too few arguments')
|
||||||
|
|
||||||
write_config()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
Loading…
Reference in a new issue