added remove action
This commit is contained in:
parent
552e16e9cf
commit
5602893670
|
@ -291,6 +291,22 @@ def post_pack():
|
||||||
print('Success!')
|
print('Success!')
|
||||||
|
|
||||||
|
|
||||||
|
def remove_mod(target, delete):
|
||||||
|
"""
|
||||||
|
Removes a mod from the modpack.
|
||||||
|
"""
|
||||||
|
mod = get_mod(target)
|
||||||
|
if delete:
|
||||||
|
os.remove(os.path.join("mods", mod.filename))
|
||||||
|
else:
|
||||||
|
os.makedirs("mods_old", exist_ok=True)
|
||||||
|
os.rename(os.path.join("mods", mod.filename),
|
||||||
|
os.path.join("mods_old", mod.filename))
|
||||||
|
_cur.execute("DELETE FROM mod WHERE url = ?", (target,))
|
||||||
|
log_change(f"Removed {mod.title}")
|
||||||
|
print(f"Removed {mod.title}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
@ -300,7 +316,8 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"action",
|
"action",
|
||||||
choices=["add", "add_all", "update", "update_all", "summary", "post"],
|
choices=["add", "add_all", "update", "update_all", "summary",
|
||||||
|
"post", "remove"],
|
||||||
help="What action to perform.",
|
help="What action to perform.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -336,3 +353,5 @@ if __name__ == "__main__":
|
||||||
generate_summary()
|
generate_summary()
|
||||||
elif args.action == "post":
|
elif args.action == "post":
|
||||||
post_pack()
|
post_pack()
|
||||||
|
elif args.action == "remove":
|
||||||
|
remove_mod(args.target, args.delete)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user