Repository navigation
Conversation
Step 2 of #710. A command's logic was split between cmd and stage-shaped app calls; cmd now parses flags, calls one function and prints what it returns. An error means the command never ran, and a run that ended early says so in Summary.Err.
A missing output directory was reported only after the keys were retrieved or the files copied.
Restore now discovers its directories in an archive itself, so the command layer no longer holds the data it reads.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #710. Step 2 of 4.
internal/appexports one function per command.cmdparses flags, calls it, and prints what it returns.dumpValidateDumpDumpDiscovery,SummarydumpkeysValidateDumpKeysDumpKeysarchiveValidateArchiveArchiveDiscovery, file countrestoreValidateRestoreRestoreDiscovery,SummarylistListDiscovery,Summary--data-dirand--data-zipmove fromcmdinto these functions.Target,KeychainConfig,ListOptions,Execute,ExecuteWithKeys,CountRecords, and the exportedDiscoverandDiscoverRestoreare gone.Summary.Err, besideResult.ErrandDirFailure.Err. Every command incmdnow checkserrfirst, where each used to read the results before it in its own order.cmddefines the shared flags once:addOutputFlagsfordumpandrestore, andaddPasswordFlagsfor the two password flag pairs.snapshot.UnzipandRoot.Pathare removed, andrestoreunzips into its own temporary directory.snapshot.Openstays for the base packages' tests, which read a fixture directory in place.One behavior change, in its own commit:
dumpkeys -oandarchive -oare checked before any work. A missing output directory used to be reported only after the keys were retrieved or the files copied. As a consequence,archive -o <missing dir>/a.zipnow fails even when no browser is found.RFC-001 no longer lists the data a restore reads among what the command layer holds.
Verification
HBD_UPDATE_GOLDEN=1rewrites none of them.mainand one from this branch print the same, exit the same, and write the same files for 34 invocations: 18 with an empty home, and 16 with fixture data, including an output file that cannot be written.-ocheck, a rejected archive leaving no temporary directory behind, and a restore whose output cannot be written returning an error. Droppingreturn summary.Errfromdumporrestorefails a test.Checklist
mainbranchgo 1.20(do not bump)