Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Jul 17, 2024
1 parent 74f6a7f commit 9cc24af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,11 @@ jobs:
- name: Launch linupdate
run: python3 /opt/linupdate/linupdate.py --check-updates

- name: Test some params
run: |
python3 /opt/linupdate/linupdate.py --help
python3 /opt/linupdate/linupdate.py --version
python3 /opt/linupdate/linupdate.py --check-updates
python3 /opt/linupdate/linupdate.py --profile container
python3 /opt/linupdate/linupdate.py --env test
35 changes: 12 additions & 23 deletions src/controllers/Args.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Import libraries
from colorama import Fore, Style

import sys
import argparse

# Import classes
Expand All @@ -22,21 +22,10 @@ def preParse(self):
# Default values
Args.from_agent = False

# Parse arguments
parser = argparse.ArgumentParser()

# Define valid arguments

# Agent
parser.add_argument("--from-agent", action="store_true", default="null", help="")

# Parse arguments
args, unknown = parser.parse_known_args()

#
# If --from-agent param has been set
#
if args.from_agent != "null":
if '--from-agent' in sys.argv:
Args.from_agent = True


Expand Down Expand Up @@ -66,23 +55,23 @@ def parse(self):
# Define valid arguments

# Version
parser.add_argument("-V", "--version", action="store_true", default="null", help="Show version")
parser.add_argument("--version", "-v", action="store_true", default="null", help="Show version")
# Verbosity
parser.add_argument("-v", "--verbosity", action="store_true", default="null", help="Increase verbosity")
parser.add_argument("--verbosity", action="store_true", default="null", help="Increase verbosity")
# Force / assume-yes
parser.add_argument("-y", "--assume-yes", action="store_true", default="null", help="Answer yes to all questions")
parser.add_argument("--assume-yes", "-y", action="store_true", default="null", help="Answer yes to all questions")
# Check updates
parser.add_argument("-cu", "--check-updates", action="store_true", default="null", help="Only check for updates and exit")
parser.add_argument("--check-updates", "-cu", action="store_true", default="null", help="Only check for updates and exit")
# Ignore exclude
parser.add_argument("-ie", "--ignore-exclude", action="store_true", default="null", help="Ignore all package exclusions")
parser.add_argument("--ignore-exclude", "-ie", action="store_true", default="null", help="Ignore all package exclusions")

# Profile
parser.add_argument("-p", "--profile", action="store", nargs='?', default="null", help="Print current profile or set profile")
parser.add_argument("--profile", "-p", action="store", nargs='?', default="null", help="Print current profile or set profile")
# Environment
parser.add_argument("-e", "--env", action="store", nargs='?', default="null", help="Print current environment or set environment")
parser.add_argument("--env", "-e", action="store", nargs='?', default="null", help="Print current environment or set environment")

# Dist upgrade
parser.add_argument("-du", "--dist-upgrade", action="store_true", default="null", help="Perform a distribution upgrade (Debian based OS only)")
parser.add_argument("--dist-upgrade", "-du", action="store_true", default="null", help="Perform a distribution upgrade (Debian based OS only)")
# Keep oldconf
parser.add_argument("--keep-oldconf", action="store_true", default="null", help="Keep old configuration files during package update (Debian based OS only)")

Expand Down Expand Up @@ -112,8 +101,8 @@ def parse(self):
args, unknown = parser.parse_known_args()

# If unknown arguments are passed
# if unknown:
# raise Exception('unknown argument(s): ' + str(unknown))
if unknown:
raise Exception('unknown argument(s): ' + str(unknown))

except Exception as e:
raise Exception('Error while parsing arguments: ' + str(e))
Expand Down

0 comments on commit 9cc24af

Please sign in to comment.