Skip to content

Commit

Permalink
update-presets list-non-default: Option to format as Rust expression …
Browse files Browse the repository at this point in the history
…for midos.house codebase
  • Loading branch information
fenhl committed Aug 15, 2024
1 parent c6fbd02 commit b683f90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions update-presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Usage:
update-presets.py [options]
update-presets.py add <preset>
update-presets.py list-non-default <preset>
update-presets.py list-non-default [--rust] <preset>
update-presets.py diff <left> <right>
update-presets.py (-h | --help)
Expand All @@ -13,6 +13,7 @@
--from=<rev> update presets to match the given git commit
--hook run noninteractively for git pre-commit hook purposes
--preset=<preset> only update the named preset
--rust list non-default settings in Rust syntax appropriate for the midos.house codebase
"""

import sys
Expand Down Expand Up @@ -106,7 +107,15 @@ def get_preset(presets, name):
if preset is None:
preset = json.loads(subprocess.run([sys.executable, 'OoTRandomizer.py', '--convert_settings', '--settings_string', arguments['<preset>']], stdout=subprocess.PIPE, encoding='utf-8', check=True).stdout)
non_default = {name: value for name, value in preset.items() if value != SETTINGS_DICT[name].default}
print(json.dumps(non_default, indent=4))
if arguments['--rust']:
print('collect![')
for name, value in non_default.items():
if name == 'aliases':
continue
print('\n '.join(f' format!("{name}") => json!({json.dumps(value, indent=4)}),'.splitlines())) #TODO trailing commas in arrays/objects
print(']')
else:
print(json.dumps(non_default, indent=4))
elif arguments['diff']:
if arguments['<left>'] == 'default':
left = {setting_name: setting.default for setting_name, setting in SETTINGS_DICT.items() if setting.shared or setting_name == 'aliases'}
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__version__ = '8.1.69'

# This is a supplemental version number for branches based off of main dev.
supplementary_version = 1
supplementary_version = 2

# Pick a unique identifier byte for your fork if you are intending to have a long-lasting branch.
# This will be 0x00 for main releases and 0x01 for main dev.
Expand Down

0 comments on commit b683f90

Please sign in to comment.