Skip to content

Commit

Permalink
Refactor the callback method in the ConfigReadCommand class to simpli…
Browse files Browse the repository at this point in the history
…fy the code and improve readability.
  • Loading branch information
WyvernIXTL committed May 19, 2024
1 parent 97ede1d commit 6b501ed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions installation_instruction/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from sys import argv, exit
from sys import exit
from os.path import isfile

import click
Expand All @@ -22,6 +22,10 @@


class ConfigReadCommand(click.MultiCommand):
"""
Custom click command class to read config file and show installation instructions with parameters.
"""

def __init__(self, *args, **kwargs):
super().__init__(
*args,
Expand All @@ -40,12 +44,8 @@ def get_command(self, ctx, config_file: str) -> click.Command|None:

def callback(**kwargs):
inst = instruction.validate_and_render(kwargs)
if not inst[1]:
print(inst[0])
exit(0)
else:
print(inst[0])
exit(1)
print(inst[0])
exit(0 if not inst[1] else 1)

return click.Command(
name=config_file,
Expand Down

0 comments on commit 6b501ed

Please sign in to comment.