mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-04-22 13:12:25 +02:00
Added --delete and browse
This commit is contained in:
parent
412a7bae16
commit
8cb2f578df
38
main.py
38
main.py
@ -176,6 +176,27 @@ def cleanup(args):
|
|||||||
"""
|
"""
|
||||||
command = ["docker", "container", "prune", "-f"]
|
command = ["docker", "container", "prune", "-f"]
|
||||||
run_command(command, args.dry_run)
|
run_command(command, args.dry_run)
|
||||||
|
|
||||||
|
def delete_portfolio_container(dry_run=False):
|
||||||
|
"""
|
||||||
|
Force remove the portfolio container if it exists.
|
||||||
|
"""
|
||||||
|
print("Checking if 'portfolio' container exists to delete...")
|
||||||
|
command = ["docker", "rm", "-f", "portfolio"]
|
||||||
|
run_command(command, dry_run)
|
||||||
|
|
||||||
|
def browse(args):
|
||||||
|
"""
|
||||||
|
Open http://localhost:5000 in Chromium browser.
|
||||||
|
|
||||||
|
Command:
|
||||||
|
chromium http://localhost:5000
|
||||||
|
|
||||||
|
This command launches the Chromium browser to view the running application.
|
||||||
|
"""
|
||||||
|
command = ["chromium", "http://localhost:5000"]
|
||||||
|
run_command(command, args.dry_run)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
@ -187,12 +208,24 @@ def main():
|
|||||||
help="Print the commands without executing them."
|
help="Print the commands without executing them."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--delete",
|
||||||
|
action="store_true",
|
||||||
|
help="Delete the existing 'portfolio' container before running the command."
|
||||||
|
)
|
||||||
|
|
||||||
subparsers = parser.add_subparsers(
|
subparsers = parser.add_subparsers(
|
||||||
title="Commands",
|
title="Commands",
|
||||||
description="Available commands to manage the application",
|
description="Available commands to manage the application",
|
||||||
dest="command"
|
dest="command"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Browse command
|
||||||
|
parser_browse = subparsers.add_parser(
|
||||||
|
"browse", help="Open http://localhost:5000 in Chromium browser."
|
||||||
|
)
|
||||||
|
parser_browse.set_defaults(func=browse)
|
||||||
|
|
||||||
# Build command
|
# Build command
|
||||||
parser_build = subparsers.add_parser(
|
parser_build = subparsers.add_parser(
|
||||||
"build", help="Build the Docker image."
|
"build", help="Build the Docker image."
|
||||||
@ -252,6 +285,9 @@ def main():
|
|||||||
if args.command is None:
|
if args.command is None:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.delete:
|
||||||
|
delete_portfolio_container(args.dry_run)
|
||||||
|
|
||||||
# Execute the chosen subcommand function
|
# Execute the chosen subcommand function
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user