Skip to content

Fix/toml insertion order#4

Merged
Lucklyric merged 8 commits intomainfrom
fix/toml-insertion-order
Jul 21, 2025
Merged

Fix/toml insertion order#4
Lucklyric merged 8 commits intomainfrom
fix/toml-insertion-order

Conversation

@Lucklyric
Copy link
Copy Markdown
Owner

This pull request introduces a significant update to the vaultify project, transitioning the vault format from Markdown to TOML. The changes improve the readability, structure, and extensibility of vault files while updating the CLI and interactive modes to reflect the new format. The most important changes are grouped below by theme.

Transition to TOML format:

  • Updated the vault format from Markdown to TOML, including changes to file extensions, structure, and content representation (e.g., vault.mdvault.toml) (README.md, src/cli.rs, src/interactive.rs, src/main.rs, Cargo.toml, [1] [2] [3] [4].
  • Enhanced the VaultEntry model to support custom fields using TOML's key-value structure and replaced slash-separated scopes with dot-separated scopes for better alignment with TOML syntax (src/models.rs, src/models.rsR4-R26).

CLI and interactive mode updates:

  • Updated CLI help messages, commands, and default file paths to reflect the TOML format (e.g., vault.mdvault.toml) (src/cli.rs, [1] [2] [3].
  • Improved scope validation and parsing to support dot-separated notation (e.g., personal.email instead of personal/email) (src/cli.rs, src/cli.rsL683-R690).

Codebase simplifications:

  • Removed the Markdown parser module (src/parser.rs) and added a new TOML parser module (src/toml_parser.rs) (src/lib.rs, src/lib.rsL10-R13).
  • Cleaned up unused fields in the VaultEntry model, such as heading_level and line-based metadata, which are no longer relevant in the TOML format (src/models.rs, src/models.rsR4-R26).

Test updates:

  • Updated test cases to reflect the transition to TOML, including file extensions, scope formats, and vault content structure (src/cli.rs, src/interactive.rs, src/gpg.rs, [1] [2] [3].

Version bump:

  • Incremented the project version from 0.2.7 to 0.3.0 in Cargo.toml to signify the breaking change in vault format (Cargo.toml, Cargo.tomlL3-R3).

…lt entries

- Fix heading level calculation: root entries now use level 2 (##) instead of level 1 (#)
  by changing formula from scope_parts.len() to scope_parts.len() + 1
- Fix blank line formatting for first entry after root header to prevent format corruption
- Add context-aware formatting with format_entry_with_context() method
- Add post-save validation to detect corruption immediately
- Add comprehensive test suite with 7 new tests for multiple root entry scenarios

These fixes ensure vault files with multiple root-level entries can be saved and loaded
reliably without data loss or corruption.
- Add TOML parser module with flexible parsing behavior
- Support implicit parent node creation
- Preserve custom fields for forward compatibility
- Add format auto-detection (Markdown vs TOML)
- Update VaultEntry to include custom_fields HashMap
- Add comprehensive test suite for TOML functionality
- Update service layer to use appropriate parser based on content
- Maintain backward compatibility with Markdown format
- Remove all alphabetical sorting from TOML parser
- Maintain exact file order when reading/writing vault files
- Implement smart group insertion: new entries are added at the end of their group
- Example: with [a.a2], [b.a2], adding [a.a11] results in [a.a2], [a.a11], [b.a2]
- Groups are determined by top-level prefix (e.g., all a.* entries stay together)
- Add comprehensive tests for insertion order preservation
- Update documentation to reflect the new behavior

This ensures vault entries maintain their original organization and new entries
are logically grouped with related items rather than appended to the end.
- Remove alphabetical sorting from TOML parser
- Maintain exact file order when reading/writing vaults
- Add smart group insertion: new entries append to their group
- Example: [a.a2], [b.a2] + [a.a11] → [a.a2], [a.a11], [b.a2]
- Groups determined by top-level prefix (all a.* stay together)

This ensures vault entries maintain logical organization with
related items grouped together rather than scattered.
- Update README to reflect TOML format instead of Markdown
- Add documentation about insertion order preservation
- Fix list commands to maintain vault file order (no sorting)
- Remove alphabetical sorting from list_scopes and list operations

This ensures the list output matches the order in the TOML file.
- Format code according to Rust standards
- Ensure CI passes with cargo fmt and cargo clippy
- Use direct variable interpolation in format strings
- Change format!("{}", var) to format!("{var}")
- Ensures CI passes with cargo clippy -- -D warnings
- Fix format string in main.rs for vault creation
- Fix format string in toml_parser.rs for custom fields
- Ensures all clippy warnings are resolved
@Lucklyric Lucklyric merged commit 5a7f0b3 into main Jul 21, 2025
1 check passed
@Lucklyric Lucklyric deleted the fix/toml-insertion-order branch July 21, 2025 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant