Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init command cannot render a help message #530

Closed
mr-cal opened this issue Oct 17, 2024 · 1 comment · Fixed by #541
Closed

Init command cannot render a help message #530

mr-cal opened this issue Oct 17, 2024 · 1 comment · Fixed by #541
Labels
Bug Something isn't working triaged

Comments

@mr-cal
Copy link
Contributor

mr-cal commented Oct 17, 2024

What needs to get done

Update craft-cli after canonical/craft-cli#292 is completed.

Why it needs to get done

Requiring access to self._app.name causes testcraft init --help to fail.

def fill_parser(self, parser: argparse.ArgumentParser) -> None:
    parser.add_argument(
        "--profile",
        type=str,
        choices=self.profiles,
        default=self.default_profile,
        help=(
            f"Use the specified project profile (default is {self.default_profile})"
            f"choices are {humanize_list(self.profiles, 'and')})"
        ),
    )

    @property
    def parent_template_dir(self) -> pathlib.Path:
        """Return the path to the directory that contains all templates."""
        with importlib.resources.path(
            self._app.name, "templates"
        ) as _parent_template_dir:
            return _parent_template_dir

    @property
    def profiles(self) -> list[str]:
        """A list of profile names generated from template directories."""
        template_dirs = [path for path in self.parent_template_dir.iterdir() if path.is_dir()]
        return [template.name for template in template_dirs]
@mr-cal mr-cal added Enhancement New feature or request Bug Something isn't working triaged and removed Enhancement New feature or request labels Oct 17, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3586.

This message was autogenerated

tigarmo added a commit that referenced this issue Oct 21, 2024
This lets commands be able to always rely on `self.config` existing, even
when running `fill_parser()` for help output.

Fixes #530
tigarmo added a commit that referenced this issue Oct 21, 2024
This lets commands be able to always rely on `self.config` existing, even
when running `fill_parser()` for help output.

Fixes #530
tigarmo added a commit that referenced this issue Oct 22, 2024
This lets commands be able to always rely on `self.config` existing, even
when running `fill_parser()` for help output.

Fixes #530
linostar pushed a commit to linostar/craft-application that referenced this issue Dec 4, 2024
This lets commands be able to always rely on `self.config` existing, even
when running `fill_parser()` for help output.

Fixes canonical#530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant