refactor(application): commands, pre-run validation
Metadata
Current evaluation
Merged after approval and CI. Refactored command handling and pre-run validation using craft-cli groups. Improved error formatting, targeted SNAPCRAFT_REMOTE_BUILD_STRATEGY validation, and fixed core20/core24 compatibility. Resolves #4911 and #5008.
Suggested action: —
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] Have you successfully run `tox run -m lint`?
- [x] Have you successfully run `tox run -e test-py310`? (supported versions: `py39`, `py310`, `py311`, `py312`)
-----
#### Refactor
1. Use craft-cli command groups
2. Stop overriding craft-applications `command_groups` property, except for the `LifecycleGroup`
3. Split the logic in `_get_dispatcher()` code into 2 places:
- Check and raise `ClassicFallback` errors before creating the dispatcher
- Check and raise `CraftErrors` if the wrong codepath or wrong version of snapcraft was chosen after creating the dispatcher
#### UX changes
1. ESM errors show a properly formatted error instead of a traceback
2. Remote build errors about `SNAPCRAFT_REMOTE_BUILD_STRATEGY` show a properly formatted error instead of a traceback
4. `SNAPCRAFT_REMOTE_BUILD_STRATEGY` is only validated when executing `snapcraft remote-build`
5. `SNAPCRAFT_REMOTE_BUILD_STRATEGY` is validated for core24 and newer snaps, rather than being ignored.
6. `snapcraft list-plugins --base=core20` no longer fails in a core24 project directory (#5008)
Fixes #4911
Fixes #5008
(CRAFT-3106)
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen/qwen3.6-35b-a3b | — | — | Merged after approval and CI. Refactored command handling and pre-run validation using craft-cli groups. Improved error formatting, targeted SNAPCRAFT_REMOTE_BUILD_STRATEGY validation, and fixed core20/core24 compatibility. Resolves #4911 and #5008. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged command group refactoring and pre-run validation. Enhanced error formatting, corrected SNAPCRAFT_REMOTE_BUILD_STRATEGY validation, and fixed a core24 list-plugins failure. Resolves #4911 and #5008. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged refactoring of application commands and pre-run validation. Adopted craft-cli command groups, improved error formatting, and corrected SNAPCRAFT_REMOTE_BUILD_STRATEGY validation. Resolved issues #4911 and #5008. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #4830 refactor: migrate commands to craft-application | snapcraft | merged | Merged following three approvals and passing CI. Migrates remaining commands to core24/craft-application, updating snapcraft init to generate core24 files, correcting list-plugins output, and refreshing command docs. Resolves #4742. | |
| #5239 refactor: use craft-application's remote-build | snapcraft | merged | Merged after three approvals. Author rebased to fix CLA. @mr-cal merged without waiting for core20 spread tests, as changes do not affect core20; related tests will run in PR #5259. | |
| #1520 refactor: remove old "init" command implementation | charmcraft | merged | Merged a refactoring PR removing the old "init" command after the craft-application transition. Approved by two reviewers with passing CI, the change modified four files, adding one line and deleting 248. | |
| #1571 refactor: remove unused clean command implementation | charmcraft | merged | Merged refactoring that removes the unused custom clean command and associated regression tests, as the project now uses the craft-application clean command. Approved by three reviewers, passed CI, and modified four files. | |
| #5129 refactor: use init command from craft-application | snapcraft | merged | Merged a refactor replacing Snapcraft's init command with craft-application's implementation. Introduces name, profile, and project-dir parameters, resolves #5098, passed CI, and received two approvals across 23 changed files. | |
| #4586 refactor: move core22 commands for versioned implementation | snapcraft | merged | Merged a pure rename refactor moving core22 commands for versioned implementation. Approved by four reviewers and passed CI. Full spread tests were enabled per request; failures attributed to external craft-application updates. | |
| #6228 refactor: migrate sign-build command | snapcraft | merged | Merged refactoring PR that migrates the sign-build command out of the legacy codebase (SNAPCRAFT-1320). Approved by two reviewers and integrated after a lint failure was resolved in a separate PR. | |
| #3939 command: update edit-validation-sets to craft-cli | snapcraft | merged | Merged migration of edit-validation-sets to craft-cli. Replaces click with emit for output, refactors file editing to use Path, updates tests, and separates validation sets into a dedicated command group. Approved and merged. | |
| #1572 refactor: remove unused extension command implementations | charmcraft | merged | Merged refactoring that removes unused extension command implementations. Tests were relocated to craft-application, with remote build fixes tracked in #1573. Approved by three reviewers, the change reduced 161 lines across six files. | |
| #521 refactor: port code to latest craft-app update | rockcraft | merged | Merged following two approvals and passing CI. Refactored image and package services to replace platform/build-for with the build plan, aligning with craft-application 2.3.0. Updates span 14 files (+106/-71 lines). |