"""
spotilyzer show-candidates subcommand
"""

# project imports
from .candidates_base import CandidatesBase
from .json.candidates import load_candidates

# constants
_DESCRIPTION = "show candidates in JSON file"
_CANDIDATES_ARG = 'candidates'


class ShowCandidates(CandidatesBase):
    """
    show-candidates subcommand
    """

    name = 'show-candidates'

    @classmethod
    def add_parser(cls, subparsers):
        """
        Add show-candidates subcommand parser.
        :param subparsers: object to attach parser
        :return: None
        """
        parser = subparsers.add_parser(cls.name, description=_DESCRIPTION,
                                       help=_DESCRIPTION)
        parser.add_argument(_CANDIDATES_ARG,
                            help="JSON output of create-candidates")

    def run(self):
        """
        Show candidates generated by create-candidates.
        :return: None
        """
        candidates = load_candidates(self.getarg(_CANDIDATES_ARG))
        self.display_candidates(candidates)
