Fix printings
This commit is contained in:
parent
0051341d5e
commit
cf7af2a2c8
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys, os, subprocess
|
||||
|
||||
def print_help():
|
||||
help_text = f"""
|
||||
Usage: {os.path.basename(__file__)} $1 $2 $3
|
||||
|
||||
|
@ -12,24 +11,22 @@ required:
|
|||
optional:
|
||||
$3 - description of service
|
||||
"""
|
||||
print(help_text)
|
||||
|
||||
number_of_required_arguments = 2
|
||||
number_of_optional_arguments = 1
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit()
|
||||
elif sys.argv[1] in ["help", "-h"]:
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit()
|
||||
elif len(sys.argv) - 1 < number_of_required_arguments:
|
||||
print(f"You provided not enough arguments")
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit(1)
|
||||
elif len(sys.argv) > number_of_required_arguments + number_of_optional_arguments + 1:
|
||||
print(f"You provided extra arguments")
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit(1)
|
||||
|
||||
name_of_service = sys.argv[1]
|
||||
|
@ -38,11 +35,11 @@ description = sys.argv[3] if sys.argv[3:4] else "" # empty if no description
|
|||
|
||||
if not os.path.isabs(path_to_script):
|
||||
print("Path to script should be absolute!")
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit(1)
|
||||
elif not os.path.isfile(path_to_script):
|
||||
print("Path to script should exist and must be file!")
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys, os, subprocess
|
||||
|
||||
def print_help():
|
||||
help_text = f"""
|
||||
Usage: {os.path.basename(__file__)} $1 $2
|
||||
|
||||
|
@ -9,24 +8,22 @@ required:
|
|||
$1 - name of service
|
||||
$2 - calendar ()
|
||||
"""
|
||||
print(help_text)
|
||||
|
||||
number_of_required_arguments = 2
|
||||
number_of_optional_arguments = 0
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit()
|
||||
elif sys.argv[1] in ["help", "-h"]:
|
||||
print_help()
|
||||
sys.exit()
|
||||
print(help_text)
|
||||
elif len(sys.argv) - 1 < number_of_required_arguments:
|
||||
print(f"You provided not enough arguments")
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit(1)
|
||||
elif len(sys.argv) > number_of_required_arguments + number_of_optional_arguments + 1:
|
||||
print(f"You provided extra arguments")
|
||||
print_help()
|
||||
print(help_text)
|
||||
sys.exit(1)
|
||||
|
||||
name_of_service = sys.argv[1]
|
||||
|
|
Loading…
Reference in New Issue