11# flake8: noqa: E501
22import os
3+ import sys
34import tomllib
45import tomli_w
56import subprocess
89import argparse
910
1011
12+ def get_packwiz_command ():
13+ """Return the appropriate packwiz command based on the operating system."""
14+ if sys .platform == "win32" :
15+ return "./packwiz.exe"
16+ else :
17+ return "./packwiz"
18+
19+
1120def parse_semver (version_string ):
1221 """Parse semantic version string and return major, minor, patch components."""
1322 match = re .match (r'(\d+)\.(\d+)\.(\d+)' , version_string )
@@ -34,7 +43,7 @@ def get_outdated_mods():
3443
3544def refresh_index ():
3645 try :
37- subprocess .run (["./packwiz.exe" , "refresh" ], capture_output = True , check = True )
46+ subprocess .run ([get_packwiz_command () , "refresh" ], capture_output = True , check = True )
3847 except subprocess .CalledProcessError :
3948 pass # Ignore errors in refresh
4049
@@ -49,7 +58,7 @@ def attempt_update(mod: str, info: dict):
4958 print (f"Updating { info ['name' ]} " )
5059 # We want to run ./packwiz.exe update with the mod name
5160 # We also want to capture the output to determine if it was successful
52- result = subprocess .run (["./packwiz.exe" , "update" , mod_name , "-y" ], capture_output = True , text = True , check = False )
61+ result = subprocess .run ([get_packwiz_command () , "update" , mod_name , "-y" ], capture_output = True , text = True , check = False )
5362 # print(result.stdout)
5463 filename = info ["filename" ]
5564 # A common output of this is:
@@ -122,7 +131,7 @@ def main(args):
122131
123132 # Then just run ./packwiz.exe update --all -y for good measure
124133 try :
125- results = subprocess .run (["./packwiz.exe" , "update" , "--all" , "-y" ], capture_output = True , text = True , check = False )
134+ results = subprocess .run ([get_packwiz_command () , "update" , "--all" , "-y" ], capture_output = True , text = True , check = False )
126135 # Parse how many mods were updated. These are lines that'll be *.jar -> *.jar
127136 packwiz_updated_mods = [line for line in results .stdout .split ("\n " ) if "->" in line ]
128137 print (f"Updated { len (packwiz_updated_mods )} mods" )
0 commit comments